From: Joseph C. <tex...@us...> - 2005-09-10 08:49:49
|
Update of /cvsroot/popfile/engine/UI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25704/UI Modified Files: HTML.pm Log Message: Commit 0.23 version of Jim's bucket statistics. Needs work and discussion. Index: HTML.pm =================================================================== RCS file: /cvsroot/popfile/engine/UI/HTML.pm,v retrieving revision 1.356 retrieving revision 1.357 diff -C2 -d -r1.356 -r1.357 *** HTML.pm 21 Aug 2005 22:17:48 -0000 1.356 --- HTML.pm 10 Sep 2005 08:49:41 -0000 1.357 *************** *** 2278,2281 **** --- 2278,2302 ---- my @corpus_data; + #***** Jim's stuff 1 ***** + my $total_messages = $self->mcount__( $session ); + if ( $total_messages != 0 ) { + $templ->param( 'Corpus_If_Message_Count' => 1 ); + } + else { + $templ->param( 'Corpus_If_Message_Count' => 0 ); + } + my $total_words = 0; + for my $bucket (@buckets) { + $total_words += $self->classifier_()->get_bucket_word_count( $session, $bucket ); + } + $templ->param( 'Corpus_Word_Count' => $self->pretty_number( $total_words ) ); + if ( $total_words != 0 ) { + $templ->param( 'Corpus_If_Word_Count' => 1 ); + } + else { + $templ->param( 'Corpus_If_Word_Count' => 0 ); + } + #**** end Jim's stuff 1 **** + foreach my $bucket ( @buckets ) { my %row_data; *************** *** 2297,2300 **** --- 2318,2365 ---- $row_data{Localize_Apply} = $self->{language__}{Apply}; $row_data{Corpus_Loop_Loop_Colors} = \@color_data; + #************ Jim's stuff 2 ********* + my $messages = $self->get_bucket_parameter__( $session, $bucket, 'count' ) || 0; + if ( $total_messages == 0 ) { + $total_messages = 1; # prevent div by 0 with empty corpus (needs better solution) + } + $row_data{Bucket_Message_Percent} = sprintf( "%.2f", ( 100 * ( $messages / $total_messages ) ) ); + $row_data{Bucket_Message_Count} = $self->pretty_number( $messages ); + my $positives = $self->get_bucket_parameter__($session, $bucket, 'fpcount' ) || 0; + $row_data{Bucket_False_Positive} = $self->pretty_number( $positives ); + if ( ( $total_messages - $messages ) == 0 ) { + $row_data{Bucket_Strike_Rate} = "n/a"; + } + else { + $row_data{Bucket_Strike_Rate} = sprintf( "%.2f%%", ( 100 * ( $positives ) / ( $total_messages - $messages ) ) ); + } + my $negatives = $self->get_bucket_parameter__( $session, $bucket, 'fncount' ) || 0; + $row_data{Bucket_False_Negative} = $self->pretty_number( $negatives ); + if ( ( $messages + $negatives ) == 0 ) { + $row_data{Bucket_Hit_Rate} = "n/a"; + } + else { + $row_data{Bucket_Hit_Rate} = sprintf( "%.2f%%", ( 100 * ( $messages ) / ( $messages + $negatives ) ) ); + } + my $words = $self->classifier_()->get_bucket_word_count( $session, $bucket ) || 0; + $row_data{Bucket_Word_Count} = $self->pretty_number( $words ); + if ( $total_words != 0 ) { + $row_data{Bucket_Word_Percent} = sprintf( "%.2f", ( 100 * ( $words / $total_words ) ) ); + } + else { + $row_data{Bucket_Word_Percent} = " "; + } + if ( $messages != 0 ) { + $row_data{Bar_If_Message_Count} = 1; + } + else { + $row_data{Bar_If_Message_Count} = 0; + } + if ( $words != 0 ) { + $row_data{Bar_If_Word_Count} = 1; + } + else { + $row_data{Bar_If_Word_Count} = 0; + } + #********* end Jim's stuff 2 ******** push ( @corpus_data, \%row_data ); } |