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.

§243 ANNOYANCE-FILTER HEADER INCLUDE FILES 193<br />

}<br />

if (optind < argc) {<br />

cerr ≪ "Warning:␣command␣line␣arguments␣after␣\"−−classify␣" ≪ optarg ≪<br />

"␣will␣be␣ignored." ≪ endl ;<br />

}<br />

double score = classifyMessages (optarg );<br />

if (score ≥ junkThreshold ) {<br />

cout ≪ "JUNK" ≪ endl ;<br />

exitStatus = 3;<br />

}<br />

else if (score ≤ mailThreshold ) {<br />

cout ≪ "MAIL" ≪ endl ;<br />

exitStatus = 0;<br />

}<br />

else {<br />

cout ≪ "INDT" ≪ endl ; /∗ “INDeTerminate” ∗/<br />

exitStatus = 4;<br />

}<br />

lastOption = true ; /∗ Bail out, ignoring any (erroneous) subsequent options ∗/<br />

break;<br />

case 215: /∗ −−clearjunk Clear junk counts in dictionary ∗/<br />

dict .resetCat (dictionaryWord ::Junk );<br />

messageCount [dictionaryWord ::Junk ] = 0;<br />

break;<br />

case 216: /∗ −−clearmail Clear mail counts in dictionary ∗/<br />

dict .resetCat (dictionaryWord ::Mail );<br />

messageCount [dictionaryWord ::Mail ] = 0;<br />

break;<br />

case 200: /∗ −−copyright Print copyright information ∗/<br />

cout ≪ "This␣program␣is␣in␣the␣public␣domain.\n";<br />

return 0;<br />

case 205: /∗ −−csvread fname Import dictionary from CSV fname ∗/<br />

{<br />

ifstream is (optarg );<br />

if (¬is ) {<br />

cerr ≪ "Cannot␣open␣CSV␣dictionary␣file␣" ≪ optarg ≪ endl ;<br />

return 1;<br />

}<br />

dict .importCSV (is );<br />

if (¬singleDictionaryRead ) {<br />

updateProbability ( );<br />

}<br />

singleDictionaryRead = false ;<br />

is .close ( );<br />

}<br />

break;<br />

case 207: /∗ −−csvwrite fname Export dictionary to CSV fname ∗/<br />

{<br />

ofstream of (optarg );<br />

if (¬of ) {

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

Saved successfully!

Ooh no, something went wrong!