[cvs] bogofilter robinson.c,1.22.2.3,1.22.2.4 rstats.c,1.29.2.3,1.29.2.4
Fast Bayesian spam filter along lines suggested by Paul Graham
Brought to you by:
m-a
From: <re...@us...> - 2003-01-06 13:02:01
|
Update of /cvsroot/bogofilter/bogofilter In directory sc8-pr-cvs1:/tmp/cvs-serv14109 Modified Files: Tag: mime robinson.c rstats.c Log Message: Add some more floating point epsilon (EPS) tests. Index: robinson.c =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/robinson.c,v retrieving revision 1.22.2.3 retrieving revision 1.22.2.4 diff -u -d -r1.22.2.3 -r1.22.2.4 --- robinson.c 2 Jan 2003 21:15:00 -0000 1.22.2.3 +++ robinson.c 6 Jan 2003 13:01:56 -0000 1.22.2.4 @@ -217,7 +217,7 @@ * P = 1 - ((1-p1)*(1-p2)*...*(1-pn))^(1/n) [spamminess] * Q = 1 - (p1*p2*...*pn)^(1/n) [non-spamminess] */ - if (fabs(EVEN_ODDS - prob) >= min_dev) { + if (fabs(EVEN_ODDS - prob) - min_dev >= EPS) { P.mant *= 1-prob; if (P.mant < 1.0e-200) { P.mant *= 1.0e200; Index: rstats.c =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/rstats.c,v retrieving revision 1.29.2.3 retrieving revision 1.29.2.4 diff -u -d -r1.29.2.3 -r1.29.2.4 --- rstats.c 2 Jan 2003 14:17:39 -0000 1.29.2.3 +++ rstats.c 6 Jan 2003 13:01:57 -0000 1.29.2.4 @@ -92,8 +92,8 @@ const rstats_t *r1 = *(const rstats_t *const *)ir1; const rstats_t *r2 = *(const rstats_t *const *)ir2; - if (r1->prob > r2->prob) return 1; - if (r1->prob < r2->prob) return -1; + if (r1->prob - r2->prob > EPS) return 1; + if (r2->prob - r1->prob > EPS) return -1; return strcmp(r1->token, r2->token); } @@ -158,10 +158,10 @@ { double prob = rstats_array[r]->prob; double invn, invproduct, product, spamicity; - if (prob >= fin) + if (prob - fin >= EPS) break; - if (fabs(EVEN_ODDS - prob) >= min_dev) + if (fabs(EVEN_ODDS - prob) - min_dev >= EPS) { cnt += 1; h->prob += prob; @@ -225,7 +225,7 @@ : (pw = (cur->bad / msgs_bad) / (cur->bad / msgs_bad + cur->good / msgs_good))); double fw = (robs * robx + n * pw) / (robs + n); - char flag = (fabs(fw-EVEN_ODDS) < min_dev) ? '-' : '+'; + char flag = (fabs(fw-EVEN_ODDS) - min_dev >= EPS) ? '+' : '-'; (void)fprintf(stdout, "\"%s\"%*s %5d %8.6f %8.6f %8.6f%10.5f%10.5f %c\n", token, len, " ", |