From 132e42a9a7390eb1490f958db686d8655f171782 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 18 Jun 2015 19:02:39 +0300 Subject: limit maximum data length for bayesian processing --- plugins/af_sort_bayes/lib/class.naivebayesianstorage.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'plugins/af_sort_bayes/lib') diff --git a/plugins/af_sort_bayes/lib/class.naivebayesianstorage.php b/plugins/af_sort_bayes/lib/class.naivebayesianstorage.php index 73c1ee4c6..99db1fc79 100644 --- a/plugins/af_sort_bayes/lib/class.naivebayesianstorage.php +++ b/plugins/af_sort_bayes/lib/class.naivebayesianstorage.php @@ -47,6 +47,7 @@ class NaiveBayesianStorage { var $con = null; var $owner_uid = null; + var $max_document_length = 3000; // classifier can't rescale output for very long strings apparently function NaiveBayesianStorage($owner_uid) { $this->con = Db::get(); @@ -239,7 +240,8 @@ $this->con->escape_string($ref['document_id']) . "'"); if ($this->con->num_rows($rs) != 0) { - $ref['content'] = mb_strtolower($this->con->fetch_result($rs, 0, 'title') . ' ' . strip_tags($this->con->fetch_result($rs, 0, 'content'))); + $ref['content'] = mb_substr(mb_strtolower($this->con->fetch_result($rs, 0, 'title') . ' ' . strip_tags($this->con->fetch_result($rs, 0, 'content'))), 0, + $this->max_document_length); } } -- cgit v1.2.3