[cvs] bogofilter/src bogoutil.c,1.87,1.88
Fast Bayesian spam filter along lines suggested by Paul Graham
Brought to you by:
m-a
From: <re...@us...> - 2004-01-03 20:12:33
|
Update of /cvsroot/bogofilter/bogofilter/src In directory sc8-pr-cvs1:/tmp/cvs-serv6318 Modified Files: bogoutil.c Log Message: Add deprecated code brackets and fix spamicity calculation. Index: bogoutil.c =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/src/bogoutil.c,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -r1.87 -r1.88 --- bogoutil.c 3 Jan 2004 19:36:01 -0000 1.87 +++ bogoutil.c 3 Jan 2004 20:12:30 -0000 1.88 @@ -23,7 +23,9 @@ #include "buff.h" #include "datastore.h" #include "error.h" +#ifdef ENABLE_DEPRECATED_CODE #include "graham.h" /* for UNKNOWN_WORD */ +#endif #include "maint.h" #include "paths.h" #include "prob.h" @@ -233,9 +235,6 @@ buff_t *buff = buff_new(buf, 0, BUFSIZE); const byte *word = buf; - unsigned long spam_count, spam_msg_count = 0 ; - unsigned long good_count, good_msg_count = 0 ; - #ifndef ENABLE_DEPRECATED_CODE const char *head_format = !show_probability ? "%-30s %6s\n" : "%-30s %6s %6s %6s\n"; const char *data_format = !show_probability ? "%-30s %6lu\n" : "%-30s %6lu %6lu %f\n"; @@ -287,12 +286,14 @@ { dsv_t val; ds_get_msgcounts(dsh, &val); - spam_msg_count = val.spamcount; - good_msg_count = val.goodcount; + msgs_good = val.goodcount; + msgs_bad = val.spamcount; + robs = ROBS; + robx = ROBX; } #ifndef ENABLE_DEPRECATED_CODE - printf(head_format, "", "spam", "good", "Fisher"); + printf(head_format, "", "spam", "good", " Fisher"); #else printf(head_format, "", "spam", "good", "Gra prob", "Rob/Fis"); #endif @@ -301,6 +302,10 @@ { dsv_t val; word_t *token; + + unsigned long spam_count; + unsigned long good_count; + #ifdef ENABLE_DEPRECATED_CODE double gra_prob = 0.0; #endif @@ -322,7 +327,9 @@ spam_count = val.spamcount; good_count = val.goodcount; - if (show_probability) + if (!show_probability) + printf(data_format, token->text, spam_count, good_count); + else { #ifdef ENABLE_DEPRECATED_CODE double spamness = (double) spam_count / (double) spam_msg_count; @@ -332,17 +339,14 @@ ? UNKNOWN_WORD : spamness / (spamness+goodness); #endif - msgs_good = good_msg_count; - msgs_bad = spam_msg_count; - rob_prob = calc_prob(good_count, spam_count); - } #ifndef ENABLE_DEPRECATED_CODE - printf(data_format, token->text, spam_count, good_count, rob_prob); + printf(data_format, token->text, spam_count, good_count, rob_prob); #else - printf(data_format, token->text, spam_count, good_count, gra_prob, rob_prob); + printf(data_format, token->text, spam_count, good_count, gra_prob, rob_prob); #endif + } if (token != &buff->t) word_free(token); |