AI-Classifier

 view release on metacpan or  search on metacpan

t/text.t  view on Meta::CPAN

use strict;
use warnings;

use Test::More;
use AI::Classifier::Text::Analyzer;

my $analyzer = AI::Classifier::Text::Analyzer->new();
    
ok( $analyzer, 'Analyzer created' );

my $features = {};
$analyzer->analyze( 'aaaa http://www.example.com/bbb?xx=yy&bb=cc;dd=ff', $features );
is_deeply( $features, { aaaa => 1, 'example.com' => 1, MANY_URLS => 2 } );

$features = $analyzer->analyze( 'nothing special' );
is_deeply( $features, { nothing => 1, special => 1, NO_URLS => 2 } );

my $text = 'http://www.hungry.birds! http://www.hungry.birds! http://www.hungry.birds! '
      . 'http://www.hungry.birds! http://www.hungry.birds!';
$features = {};
$analyzer->analyze_urls( \$text, $features );
is_deeply( $features, { 
        'hungry.birds!' => 5, 
        REPEATED_URLS => 2,
        MANY_URLS => 2,
    } 
);

done_testing;

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.531 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )