/**
  * Trains the filter to recognize comments like this as spam
  *
  * @param blogId The blog id
  * @param topic The topic of the comment/article that we're using to train the filter
  * @param text The text of the comment/articles that we're usingn to train the filter
  * @param userName Name of the user posting this comment/article
  * @param userEmail Email address of the user posting this comment/article
  * @param userUrl URL of the user posting this comment/article
  * @param spam Wether we should set this message as spam or not. The content will be marked
  * as non-spam by default
  * @static
  * @return true
  */
 function train($blogId, $topic, $text, $userName, $userEmail, $userUrl, $spam = false)
 {
     $tokenizer = new BayesianTokenizer();
     $tokensTopic = $tokenizer->addContextMark($tokenizer->tokenize($topic), TOKEN_TOPIC_MARK);
     $tokensText = $tokenizer->tokenize($text);
     $tokensUserName = $tokenizer->addContextMark($tokenizer->tokenize($userName), TOKEN_USER_NAME_MARK);
     $tokensUserEmail = $tokenizer->addContextMark($tokenizer->tokenize($userEmail), TOKEN_USER_EMAIL_MARK);
     $tokensUserUrl = $tokenizer->addContextMark($tokenizer->tokenize($userUrl), TOKEN_USER_URL_MARK);
     $tokens = array_merge($tokensTopic, $tokensText, $tokensUserName, $tokensUserEmail, $tokensUserUrl);
     $bayesianFilterInfos = new BayesianFilterInfos();
     $bayesianFilterInfo = $bayesianFilterInfos->getBlogBayesianFilterInfo($blogId);
     $totalSpam = $bayesianFilterInfo->getTotalSpam();
     $totalNonSpam = $bayesianFilterInfo->getTotalNonSpam();
     $bayesianTokens = new BayesianTokens();
     if ($spam) {
         $totalSpam++;
         $bayesianFilterInfos->incTotalSpam($bayesianFilterInfo->getId());
         $bayesianTokens->incSpamOccurrencesFromTokensArray($blogId, $tokens, $totalSpam, $totalNonSpam);
     } else {
         $totalNonSpam++;
         $bayesianFilterInfos->incTotalNonSpam($bayesianFilterInfo->getId());
         $bayesianTokens->incNonSpamOccurrencesFromTokensArray($blogId, $tokens, $totalSpam, $totalNonSpam);
     }
     return true;
 }