+ $nbs = new NaiveBayesianStorage($_SESSION["uid"]);
+ $nb = new NaiveBayesian($nbs);
+
+ $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_strtolower($title . " " . strip_tags($this->dbh->fetch_result($result, 0, "content")));
+ $score = $this->dbh->fetch_result($result, 0, "score");
+
+ $this->dbh->query("BEGIN");
+
+ if ($nb->untrain($guid, $content)) {
+ if ($score >= $this->score_modifier) $score -= $this->score_modifier;
+ }
+
+ $nb->train($guid, $nbs->getCategoryByName($category), $content);
+
+ if ($category == "GOOD") $score += $this->score_modifier;
+
+ $this->dbh->query("UPDATE ttrss_user_entries SET score = '$score' WHERE ref_id = $article_id AND owner_uid = " . $_SESSION["uid"]);
+
+ $nb->updateProbabilities();
+
+ $this->dbh->query("COMMIT");
+
+ }
+
+ print "$article_id :: $category";