예제 #1
0
파일: App.php 프로젝트: Hildy/cerb5
 function showTab()
 {
     @($ticket_id = DevblocksPlatform::importGPC($_REQUEST['ticket_id'], 'integer', 0));
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = dirname(dirname(__FILE__)) . '/templates/';
     $tpl->assign('path', $tpl_path);
     $ticket = DAO_Ticket::getTicket($ticket_id);
     $tpl->assign('ticket_id', $ticket_id);
     $tpl->assign('ticket', $ticket);
     // Receate the original spam decision
     $words = DevblocksPlatform::parseCsvString($ticket->interesting_words);
     $words = DAO_Bayes::lookupWordIds($words);
     // Calculate word probabilities
     foreach ($words as $idx => $word) {
         /* @var $word CerberusBayesWord */
         $word->probability = CerberusBayes::calculateWordProbability($word);
     }
     $tpl->assign('words', $words);
     // Determine what the spam probability would be if the decision was made right now
     $analysis = CerberusBayes::calculateTicketSpamProbability($ticket_id, true);
     $tpl->assign('analysis', $analysis);
     $tpl->display('file:' . $tpl_path . 'ticket_tab/index.tpl');
 }
예제 #2
0
파일: Bayes.php 프로젝트: joegeck/cerb4
 /**
  * @param array $words An array indexed with words to look up 
  */
 private static function _lookupWordIds($words)
 {
     $pos = 0;
     $batch_size = 100;
     //[TODO] Tune this
     $outwords = array();
     //
     while (array() != ($batch = array_slice($words, $pos, $batch_size, true))) {
         $batch = array_keys($batch);
         // words are now values
         $word_ids = DAO_Bayes::lookupWordIds($batch);
         $outwords = array_merge($outwords, $word_ids);
         $pos += $batch_size;
     }
     return $outwords;
 }