Update of /cvsroot/popfile/engine/Classifier
In directory sc8-pr-cvs1:/tmp/cvs-serv11237/Classifier
Modified Files:
Bayes.pm
Log Message:
Magnets now work
Index: Bayes.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Classifier/Bayes.pm,v
retrieving revision 1.114
retrieving revision 1.115
diff -C2 -d -r1.114 -r1.115
*** Bayes.pm 5 Mar 2003 21:15:29 -0000 1.114
--- Bayes.pm 5 Mar 2003 21:58:19 -0000 1.115
***************
*** 457,466 ****
# ---------------------------------------------------------------------------------------------
#
! # save_magnets
#
# Save all the magnet definitions
#
# ---------------------------------------------------------------------------------------------
! sub save_magnets
{
my ($self) = @_;
--- 457,466 ----
# ---------------------------------------------------------------------------------------------
#
! # save_magnets__
#
# Save all the magnet definitions
#
# ---------------------------------------------------------------------------------------------
! sub save_magnets__
{
my ($self) = @_;
***************
*** 513,517 ****
my $noattype;
! $noattype = $self->{parser__}->{$type};
$noattype =~ s/[@\$]/\./g;
--- 513,517 ----
my $noattype;
! $noattype = $self->{parser__}->get_header($type);
$noattype =~ s/[@\$]/\./g;
***************
*** 1252,1255 ****
--- 1252,1256 ----
#
# ---------------------------------------------------------------------------------------------
+
sub echo_to_dot_
{
***************
*** 1267,1270 ****
--- 1268,1360 ----
last if ( /^\.(\r\n|\r|\n)$/ );
}
+ }
+
+ # ---------------------------------------------------------------------------------------------
+ #
+ # get_buckets_with_magnets
+ #
+ # Returns the names of the buckets for which magnets are defined
+ #
+ # ---------------------------------------------------------------------------------------------
+
+ sub get_buckets_with_magnets
+ {
+ my ( $self ) = @_;
+
+ return sort keys %{$self->{magnets__}};
+ }
+
+ # ---------------------------------------------------------------------------------------------
+ #
+ # get_magnet_types_in_bucket
+ #
+ # Returns the types of the magnetsd in a specific bucket
+ #
+ # $bucket The bucket to search for magnets
+ #
+ # ---------------------------------------------------------------------------------------------
+
+ sub get_magnet_types_in_bucket
+ {
+ my ( $self, $bucket ) = @_;
+
+ return sort keys %{$self->{magnets__}{$bucket}};
+ }
+
+ # ---------------------------------------------------------------------------------------------
+ #
+ # get_magnets
+ #
+ # Returns the magnets of a certain type in a bucket
+ #
+ # $bucket The bucket to search for magnets
+ #
+ # ---------------------------------------------------------------------------------------------
+
+ sub get_magnets
+ {
+ my ( $self, $bucket, $type ) = @_;
+
+ return sort keys %{$self->{magnets__}{$bucket}{$type}};
+ }
+
+ # ---------------------------------------------------------------------------------------------
+ #
+ # create_magnet
+ #
+ # Make a new magnet
+ #
+ # $bucket The bucket the magnet belongs in
+ # $type The magnet type (e.g. from, to or subject)
+ # $text The text of the magnet
+ #
+ # ---------------------------------------------------------------------------------------------
+
+ sub create_magnet
+ {
+ my ( $self, $bucket, $type, $text ) = @_;
+
+ $self->{magnets__}{$bucket}{$type}{$text} = 1;
+ $self->save_magnets__();
+ }
+
+ # ---------------------------------------------------------------------------------------------
+ #
+ # delete_magnet
+ #
+ # Remove a new magnet
+ #
+ # $bucket The bucket the magnet belongs in
+ # $type The magnet type (e.g. from, to or subject)
+ # $text The text of the magnet
+ #
+ # ---------------------------------------------------------------------------------------------
+
+ sub delete_magnet
+ {
+ my ( $self, $bucket, $type, $text ) = @_;
+
+ delete $self->{magnets__}{$bucket}{$type}{$text};
+ $self->save_magnets__();
}
|