AI-Classifier-Japanese
view release on metacpan or search on metacpan
use strict;
use Test::More;
use AI::Classifier::Japanese;
my $classifier = AI::Classifier::Japanese->new();
my $CATEGORY_POSITIVE = "positive";
my $CATEGORY_NEGATIVE = "negative";
$classifier->add_training_text("ãã®ãã", $CATEGORY_POSITIVE);
$classifier->add_training_text("楽ãã", $CATEGORY_POSITIVE);
$classifier->add_training_text("ã¤ãã", $CATEGORY_NEGATIVE);
$classifier->add_training_text("è¾ã", $CATEGORY_NEGATIVE);
$classifier->train;
my $result_ref = $classifier->predict("ãã®ãã");
my $result_posi = $result_ref->{$CATEGORY_POSITIVE};
my $result_nega = $result_ref->{$CATEGORY_NEGATIVE};
cmp_ok($result_posi, '>', 0.85,
"Expected to be larger than 0.85, thoguh the value was $result_nega.");
cmp_ok($result_nega, '<', 0.50,
"Expected to be smaller than 0.50, though the value was $result_nega.");
$result_ref = $classifier->predict("ã¤ãã");
$result_posi = $result_ref->{$CATEGORY_POSITIVE};
$result_nega = $result_ref->{$CATEGORY_NEGATIVE};
cmp_ok($result_posi, '<', 0.50,
"Expected to be smaller than 0.50, though the value was $result_posi.");
cmp_ok($result_nega, '>', 0.85,
"Expected to be larger than 0.85, thoguh the value was $result_nega.");
done_testing;
( run in 0.228 second using v1.01-cache-2.11-cpan-4d50c553e7e )