AI-Classifier
view release on metacpan or search on metacpan
% cpanm AI::Classifier
If you are installing into a system-wide directory, you may need to pass the
"-S" flag to cpanm, which uses sudo to install the module:
% cpanm -S AI::Classifier
## Installing with the CPAN shell
Alternatively, if your CPAN shell is set up, you should just be able to do:
% cpan AI::Classifier
## Manual installation
As a last resort, you can manually install it. Download the tarball, untar it,
then build it:
% perl Makefile.PL
% make && make test
Makefile.PL
README
README.pod
dist.ini
lib/AI/Classifier/Text.pm
lib/AI/Classifier/Text/Analyzer.pm
lib/AI/Classifier/Text/FileLearner.pm
t/data/training_cache/predictor
t/data/training_initial_features/ham/1
t/data/training_initial_features/ham/1.data
t/data/training_set_ordered/ham/2
t/data/training_set_ordered/spam/1
t/file_reader.t
t/model.dat
t/release-pod-coverage.t
t/release-pod-syntax.t
t/state.t
t/text.t
lib/AI/Classifier/Text/FileLearner.pm view on Meta::CPAN
AI::Classifier::Text::FileLearner - Training data reader for AI::NaiveBayes
=head1 VERSION
version 0.03
=head1 SYNOPSIS
use AI::Classifier::Text::FileLearner;
my $learner = AI::Classifier::Text::FileLearner->new( training_dir => 't/data/training_set_ordered/' );
my $classifier = $learner->classifier;
=head1 DESCRIPTION
This is a trainer of text classifiers. It traverses a directory filled,
interprets the subdirectories in it as category names, reads all files in them and adds them
as examples for the classifier being trained.
head1 METHODS
t/file_reader.t view on Meta::CPAN
my $iterator = AI::Classifier::Text::FileLearner->new(
training_dir => File::Spec->catdir( qw( something something else ) )
);
is(
$iterator->get_category( File::Spec->catdir( qw( something something else aaa bbb ) ) ),
'aaa',
'get_category'
);
}
my @training_dirs = qw( t data training_set_ordered );
my $iterator = AI::Classifier::Text::FileLearner->new(
training_dir => File::Spec->catdir( @training_dirs ) );
my %hash;
while( my $doc = $iterator->next ){
$hash{$doc->{file}} = $doc;
}
my $target = {
File::Spec->catfile( @training_dirs, 'spam', '1' ) => {
( run in 1.072 second using v1.01-cache-2.11-cpan-49f99fa48dc )