12.06.2015 Views

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

§178 ANNOYANCE-FILTER TOKEN PARSER 153<br />

}<br />

return true ;<br />

}<br />

continue;<br />

This code is used in section 174.<br />

179. If the user has so requested, we can assemble tokens into phrases in a given length range. <strong>The</strong><br />

default minimum and maximum length phrase is 1 word, which causes individual tokens to be returned<br />

as they are parsed. When the maximum is greater than one word, consecutive tokens (but never crossing<br />

a reset or setSource boundary) are assembled into phrases and output as pseudo-tokens of each length<br />

from the minimum to maximum length phrase.<br />

Here we examine the phrase length parameters, report any erroneous specifications, and determine<br />

whether phrase assembly is required at all.<br />

〈 Check phrase assembly parameters and activate if required 179 〉 ≡<br />

assemblePhrases = false ;<br />

if ((phraseMin ≠ 1) ∨ (phraseMax ≠ 1)) {<br />

if ((phraseMin ≥ 1) ∧ (phraseMax ≥ phraseMin )) {<br />

if ((phraseLimit > 0) ∧ (phraseLimit < ((phraseMax ∗ 2) − 1))) {<br />

cerr ≪ "Invalid␣−−phraselimit␣setting.␣␣Too␣small␣for␣specified␣−−phrasemax." ≪<br />

endl ;<br />

}<br />

else {<br />

assemblePhrases = true ;<br />

}<br />

}<br />

else {<br />

cerr ≪ "Invalid␣−−phrasemin/max␣parameters.␣␣Must␣be␣1␣

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

Saved successfully!

Ooh no, something went wrong!