AI-CRM114

 view release on metacpan or  search on metacpan

lib/AI/CRM114.pm  view on Meta::CPAN


use 5.008000;
use strict;
use warnings;
use IPC::Run qw /run/;

our @ISA = qw();

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;



( run in 0.315 second using v1.01-cache-2.11-cpan-a5abf4f5562 )