NonSpamWords |
Top Previous Next |
Example projects > Plain text parsers > NonSpamWords
The project Nonspamwords.ttp is suitable to carry out a first test of the IMP filter after installation. The filter should have a high priority with this project.
There are a lot of Spamihilator filters which are used to filter spam from the received e-mails. The project Nonspamwords.ttp on the other hand has a positive strategy. E-mails, which contain certain keywords, are supposed to be not spam and shall be protected from the following negative filtration. Such keywords can be the own name or the one's own company name or product names or also suitable expression of one's own special interest areas.
{{ int iResult = 0; }} SKIP? ( ( "Spamihilator" | "TextTransformer" | "tetra" ) {{ iResult = 1; }} SKIP? )? {{ out << iResult; }}
The result isn't output directly, but stored intermediately into the variable "iResultat". Only at the end of the program the value is written with the instruction "out << iResultat;". The instruction "int iResultat = 0;" is a declaration (creation) of the variables and the value 0 standing for indifference is assigned to the variable at once. This value is changed only, if the outer parenthesis (...)? is passed. The question mark means - as in the case of the regular expressions - that the expression is optional. So the occurrence of one of the words which are divided by the sign '|' is optional.
( "Spamihilator" | "TextTransformer" | "tetra" ) {{ iResult = 1; }} SKIP?
If one of the words is found in the text, the value 1 representing not spam is assigned to the variable iResult. The probably following text section is then skipped with the second SKIP until the end. If none of the non spam words occur in the text, the complete text is recognized with the first SKIP.
To cover more possible notations of the non spam words, the case sensitivity was switched off in the TextTransformer in the project options.
By two small modifications this project could be combined with the Emptymail project:
{{ int iResult = 0; }} ( SKIP ( ( "Spamihilator" | "TextTransformer" | "tetra" ) {{ iResult = 1; }} )? | {{ iResult = -1; }} ) {{ out << iResult; }}
In the "empty" alternative "| {{ iResult = -1; }}" an action is executed only, but no text is consumed. The empty alternative makes the surrounding bracket optional without '?' .
|