|
From: <jgr...@us...> - 2003-09-22 13:07:14
|
Update of /cvsroot/popfile/engine/UI
In directory sc8-pr-cvs1:/tmp/cvs-serv18165/UI
Modified Files:
HTML.pm
Log Message:
Merge Alan Beale's patch that improves the display of word probabilities
Index: HTML.pm
===================================================================
RCS file: /cvsroot/popfile/engine/UI/HTML.pm,v
retrieving revision 1.204
retrieving revision 1.205
diff -C2 -d -r1.204 -r1.205
*** HTML.pm 15 Sep 2003 15:46:24 -0000 1.204
--- HTML.pm 22 Sep 2003 13:06:39 -0000 1.205
***************
*** 204,207 ****
--- 204,211 ----
$self->config_( 'archive_classes', 0 );
+ # This setting defines what is displayed in the word matrix: 'freq' for frequencies,
+ # 'prob' for probabilities, 'score' for logarithmic scores.
+ $self->config_( 'wordtable_format', 'prob' );
+
# Load skins
***************
*** 262,265 ****
--- 266,274 ----
$self->load_history_cache__();
+ # Set the classifier option wmformat__ according to our wordtable_format
+ # option.
+
+ $self->{classifier__}->wmformat( $self->config_( 'wordtable_format' ) );
+
return $self->SUPER::start();
}
***************
*** 2215,2219 ****
my $prob = exp( $self->{classifier__}->get_value_( $bucket, $word ) );
my $n = ($total > 0)?$prob / $total:0;
! my $score = ($#buckets >= 0)?log($n)/log(@buckets)+1:0;
my $normal = sprintf("%.10f", $n);
$score = sprintf("%.10f", $score);
--- 2224,2228 ----
my $prob = exp( $self->{classifier__}->get_value_( $bucket, $word ) );
my $n = ($total > 0)?$prob / $total:0;
! my $score = ($#buckets >= 0)?(log($prob)-$self->{classifier__}->{not_likely__})/log(10.0):0;
my $normal = sprintf("%.10f", $n);
$score = sprintf("%.10f", $score);
***************
*** 3294,3297 ****
--- 3303,3315 ----
$self->{form_}{search} = '' if ( !defined( $self->{form_}{search} ) );
$self->{form_}{filter} = '' if ( !defined( $self->{form_}{filter} ) );
+ $self->{form_}{format} = '' if ( !defined( $self->{form_}{format} ) );
+
+ # If a format change was requested for the word matrix, record it in the
+ # configuration and in the classifier options.
+
+ if ( $self->{form_}{format} ne '' ) {
+ $self->config_( 'wordtable_format', $self->{form_}{format} );
+ $self->{classifier__}->wmformat( $self->{form_}{format} );
+ }
my $index = -1;
***************
*** 3383,3389 ****
--- 3401,3437 ----
$body .= "<tr>\n<td class=\"openMessageBody\"><hr><p>";
+ my $fmtlinks;
+
if ( $self->{history__}{$mail_file}{magnet} eq '' ) {
$body .= $self->{classifier__}->get_html_colored_message($self->global_config_( 'msgdir' ) . $mail_file);
+ # We want to insert a link to change the output format at the start of the word
+ # matrix. The classifier puts a comment in the right place, which we can replace
+ # by the link. (There's probably a better way.)
+
+ $fmtlinks = "<table width=\"100%\">\n<td class=\"top20\" align=\"left\"><b>$self->{language__}{View_WordMatrix}</b></td>\n<td class=\"historyNavigatorTop\">\n";
+ if ($self->config_( 'wordtable_format' ) ne 'freq' ) {
+ $fmtlinks .= "<a href=\"/view?view=" . $self->{history_keys__}[ $index ];
+ $fmtlinks .= "&start_message=". ((( $index ) >= $start_message )?$start_message:($start_message - $self->config_( 'page_size' )));
+ $fmtlinks .= $self->print_form_fields_(0,1,('filter','session','search','sort')) . "&format=freq#scores\"> ";
+ $fmtlinks .= $self->{language__}{View_ShowFrequencies};
+ $fmtlinks .= "</a> \n";
+ }
+ if ($self->config_( 'wordtable_format' ) ne 'prob' ) {
+ $fmtlinks .= "<a href=\"/view?view=" . $self->{history_keys__}[ $index ];
+ $fmtlinks .= "&start_message=". ((( $index ) >= $start_message )?$start_message:($start_message - $self->config_( 'page_size' )));
+ $fmtlinks .= $self->print_form_fields_(0,1,('filter','session','search','sort')) . "&format=prob#scores\"> ";
+ $fmtlinks .= $self->{language__}{View_ShowProbabilities};
+ $fmtlinks .= "</a> \n";
+ }
+ if ($self->config_( 'wordtable_format' ) ne 'score' ) {
+ $fmtlinks .= "<a href=\"/view?view=" . $self->{history_keys__}[ $index ];
+ $fmtlinks .= "&start_message=". ((( $index ) >= $start_message )?$start_message:($start_message - $self->config_( 'page_size' )));
+ $fmtlinks .= $self->print_form_fields_(0,1,('filter','session','search','sort')) . "&format=score#scores\"> ";
+ $fmtlinks .= $self->{language__}{View_ShowScores};
+ $fmtlinks .= "</a> \n";
+ }
+ $fmtlinks .= "</a></td></table>";
+
# Enable saving of word-scores
***************
*** 3442,3446 ****
if ($self->{history__}{$mail_file}{magnet} eq '') {
! $body .= $self->{classifier__}->scores();
$self->{classifier__}->scores('');
} else {
--- 3490,3496 ----
if ($self->{history__}{$mail_file}{magnet} eq '') {
! my $score_text = $self->{classifier__}->scores();
! $score_text =~ s/\<\!--format--\>/$fmtlinks/;
! $body .= $score_text;
$self->{classifier__}->scores('');
} else {
|