Update of /cvsroot/popfile/engine/Classifier
In directory sc8-pr-cvs1:/tmp/cvs-serv25248/Classifier
Modified Files:
Bayes.pm
Log Message:
Fix rounding problem with word counts and add new API get_count_for_word
Index: Bayes.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Classifier/Bayes.pm,v
retrieving revision 1.144
retrieving revision 1.145
diff -C2 -d -r1.144 -r1.145
*** Bayes.pm 14 May 2003 09:12:10 -0000 1.144
--- Bayes.pm 20 May 2003 20:15:02 -0000 1.145
***************
*** 1112,1115 ****
--- 1112,1135 ----
# ---------------------------------------------------------------------------------------------
#
+ # get_count_for_word
+ #
+ # Returns the number of times the word occurs in a bucket
+ #
+ # $bucket The bucket we are asking about
+ # $word The word we are asking about
+ #
+ # ---------------------------------------------------------------------------------------------
+
+ sub get_count_for_word
+ {
+ my ( $self, $bucket, $word ) = @_;
+
+ my $value = $self->get_value_( $bucket, $word );
+
+ return int( exp( $value ) * $self->get_bucket_word_count( $bucket ) + 0.5 );
+ }
+
+ # ---------------------------------------------------------------------------------------------
+ #
# get_bucket_unique_count
#
|