*/
/* Voici un petit exemple pour vous donner une idee de l'utilisation de */
/* cette class. Vous devez d'abord creer les tables necessaires avec le */
/* fichier de definition mysql.sql Attention, ne prenez pas exemple sur */
/* ce script, il est de conception rapide, juste pour presenter         */
/* l'utilisation du filtre. Il n'y a aucun controle d'erreur etc...     */
/* DEBUT CONFIGURATION */
$login = '******';
$pass = '';
$db = 'nb';
$server = 'localhost';
/* FIN CONFIGURATION */
include_once 'class.naivebayesian.php';
include_once 'class.naivebayesianstorage.php';
include_once 'class.mysql.php';
$nbs = new NaiveBayesianStorage($login, $pass, $server, $db);
$nb = new NaiveBayesian($nbs);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title>PHP Naive Bayesian Filter</title>
	<style>
	.succes { font-weight: 600; color: #00CC00; }
	.erreur { font-weight: 600; color: #CC0000; }

	</style>
</head>
Esempio n. 2
0
 function showArticleStats()
 {
     $article_id = (int) $_REQUEST["article_id"];
     $result = $this->dbh->query("SELECT score, guid, title, content FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id AND id = " . $article_id . " AND owner_uid = " . $_SESSION["uid"]);
     if ($this->dbh->num_rows($result) != 0) {
         $guid = $this->dbh->fetch_result($result, 0, "guid");
         $title = $this->dbh->fetch_result($result, 0, "title");
         $content = mb_substr(mb_strtolower($title . " " . strip_tags($this->dbh->fetch_result($result, 0, "content"))), 0, $this->max_document_length);
         print "<h2>" . $title . "</h2>";
         $nbs = new NaiveBayesianStorage($_SESSION["uid"]);
         $nb = new NaiveBayesian($nbs);
         $categories = $nbs->getCategories();
         $ref = $nbs->getReference($guid, false);
         $current_cat = isset($ref["category_id"]) ? $categories[$ref["category_id"]]["category"] : "N/A";
         print "<p>" . T_sprintf("Currently stored as: %s", $current_cat) . "</p>";
         $result = $nb->categorize($content);
         print "<h3>" . __("Classifier result") . "</h3>";
         print "<table>";
         print "<tr><th>Category</th><th>Probability</th></tr>";
         foreach ($result as $k => $v) {
             print "<tr>";
             print "<td>" . $categories[$k]["category"] . "</td>";
             print "<td>" . $v . "</td>";
             print "</tr>";
         }
         print "</table>";
     } else {
         print_error("Article not found");
     }
     print "<div align='center'>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('bayesShowDlg').hide()\">" . __('Close this window') . "</button>";
     print "</div>";
 }