From: Vsevolod Stakhov Date: Fri, 15 Nov 2013 18:39:00 +0000 (+0000) Subject: Fix bayes algorithm. X-Git-Tag: 0.6.0~59 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=29ea337d8d38af6babd3ad012b91b022a61bbb0f;p=rspamd.git Fix bayes algorithm. --- diff --git a/src/classifiers/bayes.c b/src/classifiers/bayes.c index c892488bd..184a63802 100644 --- a/src/classifiers/bayes.c +++ b/src/classifiers/bayes.c @@ -161,12 +161,12 @@ bayes_classify_callback (gpointer key, gpointer value, gpointer data) if (cur->value > 0) { cur->total_hits += cur->value; if (cur->st->is_spam) { - spam_count ++; + spam_count += cur->value; } else { - ham_count ++; + ham_count += cur->value; } - total_count ++; + total_count += cur->value; } } @@ -294,7 +294,7 @@ bayes_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, final_prob = (s + 1 - h) / 2.; } - if (final_prob > 0 && fabs (final_prob - 0.5) > 0.05) { + if (data.processed_tokens > 0 && fabs (final_prob - 0.5) > 0.05) { sumbuf = memory_pool_alloc (task->task_pool, 32); for (i = 0; i < cnt; i ++) {