From: Andrew Dolgov Date: Wed, 17 Jun 2015 16:26:50 +0000 (+0300) Subject: classifier: add workaround for division by zero X-Git-Tag: 16.3~297 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=4da0cb323f8b8450185a9cde9861bb01448935bd;p=tt-rss.git classifier: add workaround for division by zero --- diff --git a/plugins/af_sort_bayes/lib/class.naivebayesian.php b/plugins/af_sort_bayes/lib/class.naivebayesian.php index c80c3f21..da81f2aa 100644 --- a/plugins/af_sort_bayes/lib/class.naivebayesian.php +++ b/plugins/af_sort_bayes/lib/class.naivebayesian.php @@ -80,7 +80,11 @@ $scores[$category] = $data['probability']; // small probability for a word not in the category // maybe putting 1.0 as a 'no effect' word can also be good - $small_proba = 1.0 / ($data['word_count'] * 2); + + if ($data['word_count'] > 0) + $small_proba = 1.0 / ($data['word_count'] * 2); + else + $small_proba = 0; reset($tokens);