AI-CRM114
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
Revision history for Perl extension AI::CRM114.
0.01 Fri Dec 4 05:43:04 2009
- original version; created by h2xs 1.23
Changes
Makefile.PL
MANIFEST
README
t/00basic.t
t/98podsyn.t
t/99podcov.t
lib/AI/CRM114.pm
META.yml Module meta-data (added by MakeMaker)
--- #YAML:1.0
name: AI-CRM114
version: 0.01
abstract: Wrapper for the statistical data classifier CRM114
license: perl
author:
- Bjoern Hoehrmann <bjoern@hoehrmann.de>
generated_by: ExtUtils::MakeMaker version 6.42_01
distribution_type: module
requires:
IPC::Run: 0
Test::More: 0
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.3.html
version: 1.3
Makefile.PL view on Meta::CPAN
use 5.008000;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
NAME => 'AI::CRM114',
VERSION_FROM => 'lib/AI/CRM114.pm', # finds $VERSION
PREREQ_PM => {
'IPC::Run' => 0,
'Test::More' => 0,
},
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/AI/CRM114.pm', # retrieve abstract from module
AUTHOR => 'Bjoern Hoehrmann <bjoern@hoehrmann.de>') : ()),
LICENSE => 'perl',
'dist' => {
PREOP => 'chmod 600 Makefile.PL',
TARFLAGS => '--group=cpan --owner=bjoern -cvf',
},
);
AI-CRM114
=========
Please see `perldoc lib/AI/CRM114.pm` for details.
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
lib/AI/CRM114.pm view on Meta::CPAN
package AI::CRM114;
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;
__END__
=head1 NAME
AI::CRM114 - Wrapper for the statistical data classifier CRM114
=head1 SYNOPSIS
use AI::CRM114;
my $crm = AI::CRM114->new(cmd => '/path/to/crm');
# Learn new text
$crm->learn(['osb'], 'spam.css', 'MAKE MONEY FAST');
# Classify some text
my $class = $crm->classify(['osb'], ['a.css', 'b.css'], $text);
=head1 DESCRIPTION
The CRM114 Discriminator, is a collection of tools to classify data,
e.g. for use in spam filters. This module is a simple wrapper around
the command line executable. Feedback is very welcome, the interface
is unstable. Use with caution.
=head1 METHODS
=over
=item AI::CRM114->new(%options)
Creates a new instance of this class. The following options are
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
* http://crm114.sourceforge.net/
* http://crm114.sourceforge.net/docs/QUICKREF.txt
=head1 AUTHOR / COPYRIGHT / LICENSE
Copyright (c) 2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>.
This module is licensed under the same terms as Perl itself.
=cut
t/00basic.t view on Meta::CPAN
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl HTML-Encoding.t'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1;
BEGIN { use_ok('AI::CRM114') };
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
t/98podsyn.t view on Meta::CPAN
# 99pod.t -- Minimally check POD for problems.
#
# $Id$
use strict;
use warnings;
use Test::More;
eval "use Test::Pod 1.00";
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
all_pod_files_ok();
t/99podcov.t view on Meta::CPAN
# 99pod.t -- Minimally check POD for code coverage.
#
# $Id$
use strict;
use warnings;
use Test::More;
eval "use Test::Pod::Coverage";
plan skip_all => "Test::Pod::Coverage required for testing pod coverage" if $@;
plan tests => 1;
pod_coverage_ok('AI::CRM114');
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.525 second using v1.00-cache-2.02-grep-82fe00e-cpan-72ae3ad1e6da )