]> git.wh0rd.org - tt-rss.git/blobdiff - plugins/af_sort_bayes/lib/class.naivebayesian.php
classifier: add workaround for division by zero
[tt-rss.git] / plugins / af_sort_bayes / lib / class.naivebayesian.php
index c80c3f2151b27ac71a2156ca08a29ea58a8efc43..da81f2aabe5cebfc56041b7f3b213cd3a97f2514 100644 (file)
                                $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);