Update of /cvsroot/popfile/engine/Classifier
In directory sc8-pr-cvs1:/tmp/cvs-serv22382/Classifier
Modified Files:
Bayes.pm
Log Message:
Fix bug where clicking on a empty bucket caused a crash; added new clear_bucket API; added new Remove All Words button to bucket page; change the get_scores and clear_scores APIs to be a standard scores getter/setter as in the style of POPFile::Module
Index: Bayes.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Classifier/Bayes.pm,v
retrieving revision 1.134
retrieving revision 1.135
diff -C2 -d -r1.134 -r1.135
*** Bayes.pm 21 Apr 2003 08:56:51 -0000 1.134
--- Bayes.pm 21 Apr 2003 20:53:58 -0000 1.135
***************
*** 1026,1030 ****
my ( $self, $bucket ) = @_;
! return $self->{matrix__}{$bucket};
}
--- 1026,1034 ----
my ( $self, $bucket ) = @_;
! if ( $self->get_bucket_word_count( $bucket ) > 0 ) {
! return $self->{matrix__}{$bucket};
! } else {
! return ();
! }
}
***************
*** 1117,1121 ****
}
- $self->log_( "get_bucket_parameter( $bucket, $parameter ) is $param ");
return $param;
}
--- 1121,1124 ----
***************
*** 1137,1142 ****
my ( $self, $bucket, $parameter, $value ) = @_;
- $self->log_( "set_bucket_parameter( $bucket, $parameter ) to $value ");
-
$self->{parameters__}{$bucket}{$parameter} = $value;
$self->write_parameters();
--- 1140,1143 ----
***************
*** 1415,1418 ****
--- 1416,1440 ----
# ---------------------------------------------------------------------------------------------
#
+ # clear_bucket
+ #
+ # Removes all words from a bucket
+ #
+ # $bucket The bucket to clear
+ #
+ # ---------------------------------------------------------------------------------------------
+
+ sub clear_bucket
+ {
+ my ( $self, $bucket ) = @_;
+
+ my $bucket_directory = $self->config_( 'corpus' ) . "/$bucket";
+
+ unlink( "$bucket_directory/table" );
+
+ $self->load_word_matrix_();
+ }
+
+ # ---------------------------------------------------------------------------------------------
+ #
# clear_magnets
#
***************
*** 1543,1592 ****
}
! # ---------------------------------------------------------------------------------------------
! #
! # get_scores - Gets the HTMLized (for now) listing of word scores
! #
! # ---------------------------------------------------------------------------------------------
!
! sub get_scores
! {
! my ( $self ) = @_;
!
! return $self->{scores__};
! }
!
! # ---------------------------------------------------------------------------------------------
! #
! # clear_scores - clears the listing of word scores
! #
! # ---------------------------------------------------------------------------------------------
!
! sub clear_scores
! {
! my ( $self ) = @_;
!
! $self->{scores__} = '';
!
! }
!
!
! # ---------------------------------------------------------------------------------------------
! #
! # wordscores - Enables and disables the saving of word scores
! #
! # $value 1 for enabled, 0 for disabled
! #
! # ---------------------------------------------------------------------------------------------
sub wordscores
{
my ( $self, $value ) = @_;
!
$self->{wordscores__} = $value if (defined $value);
-
return $self->{wordscores__};
}
1;
--- 1565,1585 ----
}
! # GETTERS/SETTERS
sub wordscores
{
my ( $self, $value ) = @_;
!
$self->{wordscores__} = $value if (defined $value);
return $self->{wordscores__};
}
+ sub scores
+ {
+ my ( $self, $value ) = @_;
+ $self->{scores__} = $value if (defined $value);
+ return $self->{scores__};
+ }
1;
|