#!/usr/bin/perl use strict; use warnings; use Mail::Audit qw(Bayesian); use Mail::Audit::Corpus; use Time::HiRes qw(time); my $t0 = time; my $debug; if ($ARGV[0] eq "-d") { $debug = 1; shift; } my $msg = shift; # a message with an unknown charset. open(F, $msg) or die "cannot open $msg: $!"; my @l = ; close(F); my $m = Mail::Audit->new(data => \@l); my $t1 = time; print STDERR "time to read message: ", $t1 - $t0, " seconds\n"; if ($debug) { $m->{_bayesian_debug} = 1; } my @corpora = map { Mail::Audit::Corpus->new($_) } @ARGV; my $t2 = time; print STDERR "time to open corpora: ", $t2 - $t1, " seconds\n"; my @c = $m->classify(@corpora); my $t3 = time; print STDERR "time to classify message: ", $t3 - $t2, " seconds\n"; my $cm = -1; my $fm = ''; for my $i (0 .. $#ARGV) { printf ("%7.5f %s\n", $c[$i], $ARGV[$i]); if ($c[$i] > $cm) { $cm = $c[$i]; $fm = $ARGV[$i]; } } printf "%7.5f %s\n", $cm, $fm;