AI::Classifier::Text - A convenient class for text classification
version 0.03
my $cl = AI::Classifier::Text->new(classifier => AI::NaiveBayes->new(...)); my $res = $cl->classify("do cats eat bats?"); $res = $cl->classify("do cats eat bats?", { new_user => 1 }); $cl->store('some-file'); # later my $cl = AI::Classifier::Text->load('some-file'); my $res = $cl->classify("do cats eat bats?");
AI::Classifier::Text combines a lexical analyzer (by default being AI::Classifier::Text::Analyzer) and a classifier (like AI::NaiveBayes) to perform text classification.
This is partially based on AI::TextCategorizer.
classifier
An object that'll perform classification of supplied feature vectors. Has to define a classify() method, which accepts a hash refence. The return value of AI::Classifier::Text-classify()> will be the return value of classifier's classify() method.
classify()
AI::Classifier::Text-
This attribute has to be supplied to the new() method during object creation.
new()
analyzer
The class performing lexical analysis of the text in order to produce a feature vector. This defaults to AI::Classifier::Text::Analyzer.
AI::Classifier::Text::Analyzer
new(classifier => $foo)
Creates a new AI::Classifier::Text object. The classifier argument is mandatory.
AI::Classifier::Text
classify($document, $features)
Categorize the given document. A lexical analyzer will be used to extract features from $document, and in addition to that the features from $features hash reference will be added. The return value comes directly from the classifier object's classify method.
$document
$features
classify
AI::NaiveBayes (3), AI::Categorizer(3)
Zbigniew Lukasiak <zlukasiak@opera.com>, Tadeusz Sośnierz <tsosnierz@opera.com>
This software is copyright (c) 2012 by Opera Software ASA.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Sośnierz'. Assuming UTF-8
To install AI::Classifier::Text, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AI::Classifier::Text
CPAN shell
perl -MCPAN -e shell install AI::Classifier::Text
For more information on module installation, please visit the detailed CPAN module installation guide.