AI-CRM114
view release on metacpan or search on metacpan
lib/AI/CRM114.pm view on Meta::CPAN
our $VERSION = '0.01';
sub new {
my $class = shift;
my $self = { cmd => 'crm', @_ };
bless $self, $class;
return $self;
}
sub classify {
my ($self, $flags, $files, $text) = @_;
my $code = qq#-{
isolate (:stats:);
classify <@$flags> ( @$files ) (:stats:);
output /:*:stats:/
}#;
my $o = "";
my $h = run [$self->{cmd}, $code], \$text, \$o;
my ($file, $prob, $pr) = $o =~
/Best match to file \S+ \((.*?)\) +prob: *([0-9.]+) +pR: *([0-9.-]+)/;
wantarray ? ($file, $prob, $pr) : $file;
}
sub learn {
my ($self, $flags, $file, $text) = @_;
my $code = qq#-{ learn <@$flags> ( $file ) }#;
my $o = "";
my $h = run [$self->{cmd}, $code], \$text, \$o;
}
1;
__END__
=head1 NAME
lib/AI/CRM114.pm view on Meta::CPAN
available:
=over
=item cmd => '/path/to/crm'
Specifies the path to the crm executable.
=back
=item $crm->learn(\@flags, $file, $text)
Learn that the text belongs to the file using the specified flags.
Permissable flags are specified in the C<QUICKREF.txt> file that
comes with CRM114. Examples include C<winnow>, C<microgroom>, and
C<osbf>.
=item classify(\@flags, \@files, $text)
Attempt to correlate the text to one of the files using the
specified flags. Permissable flags are specified in the C<QUICKREF.txt>
file that comes with CRM114. Examples include C<unique>, C<fscm>, and
C<svm>.
In scalar context, returns the path of the best matching file.
In list context, returns a list containing the path of the best file,
and the probability and pR values as reported in C<(:stats:)>.
=back
=head1 SEE ALSO
( run in 0.271 second using v1.01-cache-2.11-cpan-94b05bcf43c )