|
From: <jgr...@us...> - 2003-04-12 21:16:58
|
Update of /cvsroot/popfile/engine/UI
In directory sc8-pr-cvs1:/tmp/cvs-serv1534/UI
Modified Files:
HTML.pm
Log Message:
Added infrastructure for QuickMagnets and made all the colorized output use words from the current language, also added false positive and false negative counting; NOTE THAT THESE ARE NOT FULLY WORKING; this check in is so that Sam and I do not diverge too much
Index: HTML.pm
===================================================================
RCS file: /cvsroot/popfile/engine/UI/HTML.pm,v
retrieving revision 1.125
retrieving revision 1.126
diff -C2 -d -r1.125 -r1.126
*** HTML.pm 12 Apr 2003 02:20:17 -0000 1.125
--- HTML.pm 12 Apr 2003 21:16:53 -0000 1.126
***************
*** 1424,1428 ****
# bar_chart_100 - Output an HTML bar chart
#
! # %values A hash of bucket names with values
#
# ---------------------------------------------------------------------------------------------
--- 1424,1428 ----
# bar_chart_100 - Output an HTML bar chart
#
! # %values A hash of bucket names with values in series 0, 1, 2, ...
#
# ---------------------------------------------------------------------------------------------
***************
*** 1433,1461 ****
my $total_count = 0;
my @xaxis = sort keys %values;
for my $bucket (@xaxis) {
! $total_count += $values{$bucket};
}
for my $bucket (@xaxis) {
! my $count = pretty_number( $self, $values{$bucket} );
! my $percent;
! if ( $total_count == 0 ) {
! $percent = "0%";
! } else {
! $percent = int( $values{$bucket} * 10000 / $total_count ) / 100;
! $percent .= "%";
! }
! $body .= "<tr>\n<td align=\"left\"><font color=\"". $self->{classifier__}->get_bucket_color($bucket) . "\">$bucket</font></td>\n";
! $body .= "<td> </td>\n<td align=\"right\">$count ($percent)</td>\n</tr>\n";
}
! $body .= "<tr>\n<td colspan=\"3\"> </td>\n</tr>\n<tr>\n<td colspan=\"3\">\n";
if ( $total_count != 0 ) {
$body .= "<table class=\"barChart\" width=\"100%\" summary=\"$self->{language__}{Bucket_BarChartSummary}\">\n<tr>\n";
foreach my $bucket (@xaxis) {
! my $percent = int( $values{$bucket} * 10000 / $total_count ) / 100;
if ( $percent != 0 ) {
$body .= "<td bgcolor=\"" . $self->{classifier__}->get_bucket_color($bucket) . "\" title=\"$bucket ($percent%)\" width=\"";
--- 1433,1472 ----
my $total_count = 0;
my @xaxis = sort keys %values;
+ my @series = sort keys %{$values{$xaxis[0]}};
for my $bucket (@xaxis) {
! $total_count += $values{$bucket}{0};
}
for my $bucket (@xaxis) {
! $body .= "<tr>\n<td align=\"left\"><font color=\"". $self->{classifier__}->get_bucket_color($bucket) . "\">$bucket</font></td>\n<td> </td>";
! for my $s (@series) {
! my $value = $values{$bucket}{$s} || 0;
! my $count = $self->pretty_number( $value );
! my $percent = '';
!
! if ( $s == 0 ) {
! if ( $total_count == 0 ) {
! $percent = " (0%)";
! } else {
! $percent = " ( " . int( $value * 10000 / $total_count ) / 100;
! $percent .= "%)";
! }
! }
!
! $body .= "\n<td align=\"right\">$count$percent</td>";
! }
! $body .= "\n</tr>\n";
}
! my $colspan = 3;
!
! $body .= "<tr>\n<td colspan=\"$colspan\"> </td>\n</tr>\n<tr>\n<td colspan=\"$colspan\">\n";
if ( $total_count != 0 ) {
$body .= "<table class=\"barChart\" width=\"100%\" summary=\"$self->{language__}{Bucket_BarChartSummary}\">\n<tr>\n";
foreach my $bucket (@xaxis) {
! my $percent = int( $values{$bucket}{0} * 10000 / $total_count ) / 100;
if ( $percent != 0 ) {
$body .= "<td bgcolor=\"" . $self->{classifier__}->get_bucket_color($bucket) . "\" title=\"$bucket ($percent%)\" width=\"";
***************
*** 1470,1474 ****
if ( $total_count != 0 ) {
! $body .= "<tr>\n<td colspan=\"3\" align=\"right\"><span class=\"graphFont\">100%</span></td>\n</tr>\n";
}
--- 1481,1485 ----
if ( $total_count != 0 ) {
! $body .= "<tr>\n<td colspan=\"$colspan\" align=\"right\"><span class=\"graphFont\">100%</span></td>\n</tr>\n";
}
***************
*** 1509,1513 ****
if ( ( defined($self->{form_}{color}) ) && ( defined($self->{form_}{bucket}) ) ) {
! open COLOR, '>' . $self->{classifier__}->config_( 'corpus' ) . "/$self->{form_}{bucket}/color";
print COLOR "$self->{form_}{color}\n";
close COLOR;
--- 1520,1524 ----
if ( ( defined($self->{form_}{color}) ) && ( defined($self->{form_}{bucket}) ) ) {
! open COLOR, '>' . $self->module_config_( 'bayes', 'corpus' ) . "/$self->{form_}{bucket}/color";
print COLOR "$self->{form_}{color}\n";
close COLOR;
***************
*** 1734,1742 ****
$body .= "<table summary=\"\">\n<tr>\n";
$body .= "<th class=\"bucketsLabel\" scope=\"col\" align=\"left\">$self->{language__}{Bucket}</th>\n<th> </th>\n";
! $body .= "<th class=\"bucketsLabel\" scope=\"col\" align=\"right\">$self->{language__}{Bucket_ClassificationCount}</th>\n</tr>\n";
my %bar_values;
for my $bucket (@buckets) {
! $bar_values{$bucket} = $self->{classifier__}->get_bucket_parameter( $bucket, 'count' );
}
--- 1745,1758 ----
$body .= "<table summary=\"\">\n<tr>\n";
$body .= "<th class=\"bucketsLabel\" scope=\"col\" align=\"left\">$self->{language__}{Bucket}</th>\n<th> </th>\n";
! $body .= "<th class=\"bucketsLabel\" scope=\"col\" align=\"right\">$self->{language__}{Bucket_ClassificationCount}</th>\n";
! $body .= "<th class=\"bucketsLabel\" scope=\"col\" align=\"right\">$self->{language__}{Bucket_ClassificationFP}</th>\n";
! $body .= "<th class=\"bucketsLabel\" scope=\"col\" align=\"right\">$self->{language__}{Bucket_ClassificationFN}</th>\n</tr>\n";
!
my %bar_values;
for my $bucket (@buckets) {
! $bar_values{$bucket}{0} = $self->{classifier__}->get_bucket_parameter( $bucket, 'count' );
! $bar_values{$bucket}{1} = $self->{classifier__}->get_bucket_parameter( $bucket, 'fpcount' );
! $bar_values{$bucket}{2} = $self->{classifier__}->get_bucket_parameter( $bucket, 'fncount' );
}
***************
*** 1750,1754 ****
for my $bucket (@buckets) {
! $bar_values{$bucket} = $self->{classifier__}->get_bucket_word_count($bucket);
}
--- 1766,1772 ----
for my $bucket (@buckets) {
! $bar_values{$bucket}{0} = $self->{classifier__}->get_bucket_word_count($bucket);
! delete $bar_values{$bucket}{1};
! delete $bar_values{$bucket}{2};
}
***************
*** 2349,2356 ****
$self->log_( "Reclassifying $mail_file from $bucket to $newbucket" );
! $self->{classifier__}->set_bucket_parameter( $newbucket, 'count',
! $self->{classifier__}->get_bucket_parameter( $newbucket, 'count' ) + 1 );
! $self->{classifier__}->set_bucket_parameter( $bucket, 'count',
! $self->{classifier__}->get_bucket_parameter( $bucket, 'count' ) - 1 );
# Update the class file
--- 2367,2381 ----
$self->log_( "Reclassifying $mail_file from $bucket to $newbucket" );
! if ( $bucket ne $newbucket ) {
! $self->{classifier__}->set_bucket_parameter( $newbucket, 'count',
! $self->{classifier__}->get_bucket_parameter( $newbucket, 'count' ) + 1 );
! $self->{classifier__}->set_bucket_parameter( $bucket, 'count',
! $self->{classifier__}->get_bucket_parameter( $bucket, 'count' ) - 1 );
!
! $self->{classifier__}->set_bucket_parameter( $newbucket, 'fncount',
! $self->{classifier__}->get_bucket_parameter( $newbucket, 'fncount' ) + 1 );
! $self->{classifier__}->set_bucket_parameter( $bucket, 'fpcount',
! $self->{classifier__}->get_bucket_parameter( $bucket, 'fpcount' ) + 1 );
! }
# Update the class file
***************
*** 2407,2410 ****
--- 2432,2440 ----
$self->{classifier__}->set_bucket_parameter( $usedtobe, 'count',
$self->{classifier__}->get_bucket_parameter( $usedtobe, 'count' ) + 1 );
+
+ $self->{classifier__}->set_bucket_parameter( $bucket, 'fncount',
+ $self->{classifier__}->get_bucket_parameter( $bucket, 'fncount' ) - 1 );
+ $self->{classifier__}->set_bucket_parameter( $usedtobe, 'fpcount',
+ $self->{classifier__}->get_bucket_parameter( $usedtobe, 'fpcount' ) - 1 );
}
***************
*** 2819,2823 ****
$body .= "<table><tr><td class=\"top20\" valign=\"top\">\n";
! $self->{classifier__}->classify_file($self->global_config_( 'msgdir' ) . "$self->{form_}{view}");
$body .= $self->{classifier__}->{scores__};
$body .= "</tr></table></td>\n</tr>\n";
--- 2849,2853 ----
$body .= "<table><tr><td class=\"top20\" valign=\"top\">\n";
! $self->{classifier__}->classify_file($self->global_config_( 'msgdir' ) . "$self->{form_}{view}", $self);
$body .= $self->{classifier__}->{scores__};
$body .= "</tr></table></td>\n</tr>\n";
***************
*** 3189,3192 ****
--- 3219,3236 ----
return $self->{classifier__};
+ }
+
+ sub language
+ {
+ my ( $self ) = @_;
+
+ return %{$self->{language__}};
+ }
+
+ sub session_key
+ {
+ my ( $self ) = @_;
+
+ return $self->{session_key__};
}
|