|
From: <jgr...@us...> - 2003-07-27 19:07:23
|
Update of /cvsroot/popfile/engine/Classifier
In directory sc8-pr-cvs1:/tmp/cvs-serv23853/Classifier
Modified Files:
Bayes.pm
Log Message:
More tests for Bayes covering the reading and writing of history class files and other miscellanea
Index: Bayes.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Classifier/Bayes.pm,v
retrieving revision 1.174
retrieving revision 1.175
diff -C2 -d -r1.174 -r1.175
*** Bayes.pm 27 Jul 2003 18:26:14 -0000 1.174
--- Bayes.pm 27 Jul 2003 19:07:20 -0000 1.175
***************
*** 188,193 ****
if ( $type eq 'CLASS' ) {
! $self->set_bucket_parameter( $message, 'count',
! $self->get_bucket_parameter( $message, 'count' ) + 1 );
$self->write_parameters();
}
--- 188,192 ----
if ( $type eq 'CLASS' ) {
! $self->set_bucket_parameter( $message, 'count', $self->get_bucket_parameter( $message, 'count' ) + 1 );
$self->write_parameters();
}
***************
*** 381,394 ****
if ( $color eq '' ) {
! if ( $c <= $#{$self->{possible_colors__}} ) {
! $self->{colors__}{$bucket} = $self->{possible_colors__}[$c];
! } else {
! $self->{colors__}{$bucket} = 'black';
! }
} else {
$self->{colors__}{$bucket} = $color;
}
! $c += 1;
}
--- 380,389 ----
if ( $color eq '' ) {
! $self->{colors__}{$bucket} = $self->{possible_colors__}[$c];
} else {
$self->{colors__}{$bucket} = $color;
}
! $c = ($c+1) % $#{$self->{possible_colors__}};
}
***************
*** 492,502 ****
if ( open WORDS, '<' . $self->config_( 'corpus' ) . "/$bucket/table" ) {
my $first = <WORDS>;
! if ( $first =~ s/^__CORPUS__ __VERSION__ (\d+)// ) {
if ( $1 != $self->{corpus_version__} ) {
! print "Incompatible corpus version in $bucket\n";
! return;
}
} else {
! return;
}
--- 487,497 ----
if ( open WORDS, '<' . $self->config_( 'corpus' ) . "/$bucket/table" ) {
my $first = <WORDS>;
! if ( defined( $first ) && ( $first =~ s/^__CORPUS__ __VERSION__ (\d+)// ) ) {
if ( $1 != $self->{corpus_version__} ) {
! print STDERR "Incompatible corpus version in $bucket\n";
! return 0;
}
} else {
! return 0;
}
***************
*** 522,525 ****
--- 517,522 ----
$self->calculate_magnet_count__();
+
+ return 1;
}
***************
*** 882,893 ****
if ( defined( $magnet ) && ( $magnet ne '' ) ) {
print CLASS "$bucket MAGNET $magnet\n";
- } elsif (defined $reclassified && $reclassified == 1) {
- print CLASS "RECLASSIFIED\n";
- print CLASS "$bucket\n";
- if ( defined( $usedtobe ) && ( $usedtobe ne '' ) ) {
- print CLASS "$usedtobe\n";
- }
} else {
! print CLASS "$bucket\n";
}
--- 879,892 ----
if ( defined( $magnet ) && ( $magnet ne '' ) ) {
print CLASS "$bucket MAGNET $magnet\n";
} else {
! if ( defined( $reclassified ) && ( $reclassified == 1 ) ) {
! print CLASS "RECLASSIFIED\n";
! print CLASS "$bucket\n";
! if ( defined( $usedtobe ) && ( $usedtobe ne '' ) ) {
! print CLASS "$usedtobe\n";
! }
! } else {
! print CLASS "$bucket\n";
! }
}
***************
*** 897,901 ****
# ---------------------------------------------------------------------------------------------
#
! # history_load_class - load the class file for a message.
#
# returns: ( reclassified, bucket, usedtobe, magnet )
--- 896,900 ----
# ---------------------------------------------------------------------------------------------
#
! # history_read_class - load the class file for a message.
#
# returns: ( reclassified, bucket, usedtobe, magnet )
***************
*** 909,913 ****
#
# ---------------------------------------------------------------------------------------------
! sub history_load_class
{
my ( $self, $filename ) = @_;
--- 908,912 ----
#
# ---------------------------------------------------------------------------------------------
! sub history_read_class
{
my ( $self, $filename ) = @_;
***************
*** 938,941 ****
--- 937,942 ----
} else {
$self->log_( "Error: " . $self->global_config_( 'msgdir' ) . "$filename: $!" );
+
+ return ( undef, undef, undef, undef );
}
return ( $reclassified, $bucket, $usedtobe, $magnet );
***************
*** 1865,1868 ****
--- 1866,1870 ----
delete $self->{magnets__};
+ $self->calculate_magnet_count__();
}
|