[pLog-CVS] plog/class/security bayesianfilter.class.php,1.5,1.6
Brought to you by:
jondaley
From: <phu...@us...> - 2004-02-07 19:34:18
|
Update of /cvsroot/plog/plog/class/security In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16158 Modified Files: bayesianfilter.class.php Log Message: I think that the bayesian filter should work now :) After updating the code, please clear the plog_bayesian_tokens table and and a single record to the plog_bayesian_filter_info table like this: insert into plog_bayesian_filter_info values(1,1,0,0); Also some testing would be needed, even though a few (many) spam observations would be needed for the filter to start working reliably... Index: bayesianfilter.class.php =================================================================== RCS file: /cvsroot/plog/plog/class/security/bayesianfilter.class.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** bayesianfilter.class.php 29 Jan 2004 20:50:45 -0000 1.5 --- bayesianfilter.class.php 7 Feb 2004 19:01:08 -0000 1.6 *************** *** 96,104 **** --- 96,111 ---- _debug("comment has been thrown away!<br/>"); } + $spam = true; } else { $result = new PipelineResult(true); + $spam = false; } + + // train the filter with the message, be it spam or not... + _debug("training the filter with spam = $spam<br/>"); + BayesianFilterCore::train( $blogInfo->getId(), $commentTopic, $commentText, $userName, $userEmail, + $userUrl, $spam ); print "<h1>" . number_format($spamicity * 100, 0) . "% of spamicity</h1>"; *************** *** 135,139 **** $bayesianFilterInfos = new BayesianFilterInfos(); $bayesianFilterInfo = $bayesianFilterInfos->getBlogBayesianFilterInfo($blogId); - print_r($bayesianFilterInfo); $totalSpam = $bayesianFilterInfo->getTotalSpam(); --- 142,145 ---- *************** *** 145,149 **** { _debug("updating occurrences for token $token<br/>"); ! $bayesianTokens->updateOccurrences($blogId, $token, 0, 0, $totalSpam, $totalNonSpam); } --- 151,155 ---- { _debug("updating occurrences for token $token<br/>"); ! $bayesianTokens->updateOccurrences($blogId, $token, 0, 0, $totalSpam, $totalNonSpam, false); } |