12.06.2015 Views

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

184 MAIN PROGRAM ANNOYANCE-FILTER §231<br />

231. <strong>The</strong> classifyMessages function classifies the first message in the mail folder fname .<br />

〈 Global functions 184 〉 +≡<br />

static double classifyMessages (const char ∗fname )<br />

{<br />

double jp;<br />

if (dict .empty ( ) ∧ ¬fDict .isDictionaryLoaded ( )) {<br />

cerr ≪ "You␣cannot␣−−classify␣or␣−−test␣a␣message␣""unless␣you␣have␣fir\<br />

st␣loaded␣a␣dictionary." ≪ endl ;<br />

jp = 0.5; /∗ Beats me–call it fifty-fifty junk probability ∗/<br />

}<br />

else {<br />

mailFolder mf (fname , dictionaryWord ::Mail );<br />

classifyMessage cm (mf , dict , &fDict , significantWords , novelWordProbability );<br />

jp = cm .classifyThis ( );<br />

if (verbose ) {<br />

cerr ≪ "Message␣junk␣probability:␣" ≪ setprecision (5) ≪ jp ≪ endl ;<br />

}<br />

}<br />

nTested ++;<br />

return jp;<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!