AI-Classifier-Japanese

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

   "prereqs" : {
      "configure" : {
         "requires" : {
            "CPAN::Meta" : "0",
            "CPAN::Meta::Prereqs" : "0",
            "Module::Build" : "0.38"
         }
      },
      "develop" : {
         "requires" : {
            "Test::CPAN::Meta" : "0",
            "Test::MinimumVersion" : "0.10108",
            "Test::Pod" : "1.41",
            "Test::Spellunker" : "v0.2.7"
         }
      },
      "runtime" : {
         "requires" : {
            "Algorithm::NaiveBayes" : "0",
            "Mouse" : "0",
            "Text::MeCab" : "0",
            "perl" : "5.008005"
         }
      },
      "test" : {
         "requires" : {
            "Test::File" : "0",
            "Test::More" : "0.98"
         }
      }
   },
   "provides" : {
      "AI::Classifier::Japanese" : {
         "file" : "lib/AI/Classifier/Japanese.pm",
         "version" : "0.01"
      }
   },
   "release_status" : "stable",

META.yml  view on Meta::CPAN

---
abstract: 'the combination wrapper of Algorithm::NaiveBayes and Text::MeCab.'
author:
  - 'Shinichi Goto <shingtgt @ GMAIL COM>'
build_requires:
  Test::File: 0
  Test::More: 0.98
configure_requires:
  CPAN::Meta: 0
  CPAN::Meta::Prereqs: 0
  Module::Build: 0.38
dynamic_config: 0
generated_by: 'Minilla/v0.11.1, CPAN::Meta::Converter version 2.120921'
license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: 1.4

README.md  view on Meta::CPAN

    # Create new instance
    my $classifier = AI::Classifier::Japanese->new();

    # Add training text
    $classifier->add_training_text("たのしい.楽しい!", 'positive');
    $classifier->add_training_text("つらい.辛い!", 'negative');

    # Train
    $classifier->train;

    # Test
    my $result_ref = $classifier->predict("たのしい");
    print $result_ref->{'positive'}; # => Confidence value

# DESCRIPTION

AI::Classifier::Japanese is a Japanese-text category classifier module using Naive Bayes and MeCab.
This module is based on Algorithm::NaiveBayes.
Only noun, verb and adjective are currently supported.

# METHODS

README.md  view on Meta::CPAN

- `$classifier->add_training_text($text, $category);`

    Add training text.

- `$classifier->train;`

    Train.

- `my $result_ref = $classifier->predict($text);`

    Test and returns a predicted result hash reference which has a confidence value for each category.

- `$classifier->save_state($params_path);`

    Save parameters.

- `$classifier->restore_state($params_path);`

    Restore parameters from a file.

- `my @labels = $classifier->labels;`

README.pod  view on Meta::CPAN

    # Create new instance
    my $classifier = AI::Classifier::Japanese->new();

    # Add training text
    $classifier->add_training_text("たのしい.楽しい!", 'positive');
    $classifier->add_training_text("つらい.辛い!", 'negative');

    # Train
    $classifier->train;

    # Test
    my $result_ref = $classifier->predict("たのしい");
    print $result_ref->{'positive'}; # => Confidence value

=head1 DESCRIPTION

AI::Classifier::Japanese is a Japanese-text category classifier module using Naive Bayes and MeCab.
This module is based on Algorithm::NaiveBayes.
Only noun, verb and adjective are currently supported.

=head1 METHODS

README.pod  view on Meta::CPAN

=item C<< $classifier->add_training_text($text, $category); >>

Add training text.

=item C<< $classifier->train; >>

Train.

=item C<< my $result_ref = $classifier->predict($text); >>

Test and returns a predicted result hash reference which has a confidence value for each category.

=item C<< $classifier->save_state($params_path); >>

Save parameters.

=item C<< $classifier->restore_state($params_path); >>

Restore parameters from a file.

=item C<< my @labels = $classifier->labels; >>

cpanfile  view on Meta::CPAN

requires 'perl', '5.008001';

requires 'Mouse';
requires 'Algorithm::NaiveBayes';
requires 'Text::MeCab';

on 'test' => sub {
    requires 'Test::More', '0.98';
    requires 'Test::File';
};

lib/AI/Classifier/Japanese.pm  view on Meta::CPAN

    # Create new instance
    my $classifier = AI::Classifier::Japanese->new();

    # Add training text
    $classifier->add_training_text("たのしい.楽しい!", 'positive');
    $classifier->add_training_text("つらい.辛い!", 'negative');

    # Train
    $classifier->train;

    # Test
    my $result_ref = $classifier->predict("たのしい");
    print $result_ref->{'positive'}; # => Confidence value

=head1 DESCRIPTION

AI::Classifier::Japanese is a Japanese-text category classifier module using Naive Bayes and MeCab.
This module is based on Algorithm::NaiveBayes.
Only noun, verb and adjective are currently supported.

=head1 METHODS

lib/AI/Classifier/Japanese.pm  view on Meta::CPAN

=item C<< $classifier->add_training_text($text, $category); >>

Add training text.

=item C<< $classifier->train; >>

Train.

=item C<< my $result_ref = $classifier->predict($text); >>

Test and returns a predicted result hash reference which has a confidence value for each category.

=item C<< $classifier->save_state($params_path); >>

Save parameters.

=item C<< $classifier->restore_state($params_path); >>

Restore parameters from a file.

=item C<< my @labels = $classifier->labels; >>

t/add_texts.t  view on Meta::CPAN

use strict;
use Test::More;

use AI::Classifier::Japanese;

my $classifier = AI::Classifier::Japanese->new();

my $CATEGORY_POSITIVE = "positive";
my $CATEGORY_NEGATIVE = "negative";

# nothing
$classifier->add_training_text("", $CATEGORY_POSITIVE);

t/all.t  view on Meta::CPAN

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);

t/base.t  view on Meta::CPAN

use strict;
use Test::More;

use_ok $_ for qw(
    AI::Classifier::Japanese
);

my $classifier = AI::Classifier::Japanese->new();

isa_ok($classifier, 'AI::Classifier::Japanese');

can_ok($classifier, $_) for qw(

t/labels.t  view on Meta::CPAN

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);

t/save_state.t  view on Meta::CPAN

use strict;
use Test::More;
use Test::File;

use AI::Classifier::Japanese;

my $classifier = AI::Classifier::Japanese->new();

my $PARAMS_PATH = "param_dummy.dat";
my $CATEGORY_POSITIVE = "positive";
my $CATEGORY_NEGATIVE = "negative";

$classifier->add_training_text("たのしい", $CATEGORY_POSITIVE);



( run in 0.555 second using v1.01-cache-2.11-cpan-4d50c553e7e )