Saving test mails

Top  Previous  Next

Further possibilities > Saving test mails

 

It is helpful during the developmental stage of a new project to be able to test the classification in the TextTransformer debugger step-by-step if it wasn't correct.

 

The project SaveTests.ttp contains code which makes, that the text of the e-mails is written into different folders depending on, whether these were indifferent mails or spam or not spam.

 

The project presupposes that there is a folder on the hard disk with the following structure:

 

..\impfilter\Spam

..\impfilter\NonSpam

..\impfilter\Indifferent

..\impfilter\OnError  // for CopyTextToDisk in NonFree

 

Either you have to create the impfilter folder on disk drive C as expected from the project or you have to adapt the path in the project:

 

{{

str sTestDir = "C:\\impfilter";    <- adapt

str sTestFile;

int iResult = 0;

}}

SpamAndNonSpam[iResult]

{{

out << 0;  // test only

 

 

switch(iResult)

{

  case 1:

  sTestDir += "\\NonSpam";

  break;

  case 0:

  sTestDir += "\\Indifferent";

  break;

  case -1:

  sTestDir += "\\Spam";

  break;

}

 

sTestFile = append_path(sTestDir, ExtraParam() + ".txt");

 

if(exists(sTestDir)) 

{

   RedirectOutput(sTestFile);

   out << xState.lp_str();   // text covered by the last production

   //out << xState.text(0);  // not allowed in the free version of TextTransformer

   //ResetOutput();

}   

}} 

 

The project doesn't affect the Spamihilator filters since the value 0 for indifferent mails is returned always. But the mail is sorted into the folders as they would be classified if iResult would be returned instead of 0.

iResult is calculated here like in the project SpamAndNonSpam. The start rule of SpamAndNonSpam is called as a sub-rule here. This is a trick, which allows to write the complete mail text with xState.lp_str() (see help to the TextTransformer). This function may be used in the free version of the TextTransformer, in contrast to the text-function, which is used in NonFree.

 

As the function CopyTextToDisk similar code is used in the project NonFree. There mails are saved too, if a parser error occurred..