Ejemplo n.º 1
0
 $time_start = microtimeFloat();
 # Include the b8 code
 require dirname(__FILE__) . "/../b8/b8.php";
 # Create a new b8 instance
 $b8 = new b8($config_b8, $config_database);
 # Check if everything worked smoothly
 $started_up = $b8->validate();
 if ($started_up !== TRUE) {
     echo "<b>example:</b> Could not initialize b8. error code: {$started_up}";
     exit;
 }
 $text = stripslashes($_POST['text']);
 $postedText = htmlentities($text, ENT_QUOTES, 'UTF-8');
 switch ($_POST['action']) {
     case "Classify":
         echo "<p><b>Spaminess: " . formatRating($b8->classify($text)) . "</b></p>\n";
         break;
     case "Save as Spam":
         $ratingBefore = $b8->classify($text);
         $b8->learn($text, b8::SPAM);
         $ratingAfter = $b8->classify($text);
         echo "<p>Saved the text as Spam</p>\n\n";
         echo "<div><table>\n";
         echo "<tr><td>Classification before learning:</td><td>" . formatRating($ratingBefore) . "</td></tr>\n";
         echo "<tr><td>Classification after learning:</td><td>" . formatRating($ratingAfter) . "</td></tr>\n";
         echo "</table></div>\n\n";
         break;
     case "Save as Ham":
         $ratingBefore = $b8->classify($text);
         $b8->learn($text, b8::HAM);
         $ratingAfter = $b8->classify($text);