From: Vsevolod Stakhov Date: Fri, 31 Mar 2017 16:19:29 +0000 (+0100) Subject: [Minor] Some fixes for displaying tokens info X-Git-Tag: 1.5.5~69 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=87820e7a7119207e0b8f5de334acb8fe4de1bd31;p=rspamd.git [Minor] Some fixes for displaying tokens info --- diff --git a/src/libstat/classifiers/bayes.c b/src/libstat/classifiers/bayes.c index 730581ced..aa6899d06 100644 --- a/src/libstat/classifiers/bayes.c +++ b/src/libstat/classifiers/bayes.c @@ -156,15 +156,30 @@ bayes_classify_token (struct rspamd_classifier *ctx, cl->ham_prob += log2 (bayes_ham_prob); cl->processed_tokens ++; - msg_debug_bayes ("token: weight: %f, total_count: %L, " - "spam_count: %L, ham_count: %L," - "spam_prob: %.3f, ham_prob: %.3f, " - "bayes_spam_prob: %.3f, bayes_ham_prob: %.3f, " - "current spam prob: %.3f, current ham prob: %.3f", - fw, total_count, spam_count, ham_count, - spam_prob, ham_prob, - bayes_spam_prob, bayes_ham_prob, - cl->spam_prob, cl->ham_prob); + if (tok->t1 && tok->t2) { + msg_debug_bayes ("token <%*s:%*s>: weight: %f, total_count: %L, " + "spam_count: %L, ham_count: %L," + "spam_prob: %.3f, ham_prob: %.3f, " + "bayes_spam_prob: %.3f, bayes_ham_prob: %.3f, " + "current spam prob: %.3f, current ham prob: %.3f", + (int) tok->t1->len, tok->t1->begin, + (int) tok->t2->len, tok->t2->begin, + fw, total_count, spam_count, ham_count, + spam_prob, ham_prob, + bayes_spam_prob, bayes_ham_prob, + cl->spam_prob, cl->ham_prob); + } + else { + msg_debug_bayes ("token : weight: %f, total_count: %L, " + "spam_count: %L, ham_count: %L," + "spam_prob: %.3f, ham_prob: %.3f, " + "bayes_spam_prob: %.3f, bayes_ham_prob: %.3f, " + "current spam prob: %.3f, current ham prob: %.3f", + fw, total_count, spam_count, ham_count, + spam_prob, ham_prob, + bayes_spam_prob, bayes_ham_prob, + cl->spam_prob, cl->ham_prob); + } } } diff --git a/src/libstat/tokenizers/osb.c b/src/libstat/tokenizers/osb.c index 7c8da26f3..8d1742cc1 100644 --- a/src/libstat/tokenizers/osb.c +++ b/src/libstat/tokenizers/osb.c @@ -346,8 +346,9 @@ rspamd_tokenizer_osb (struct rspamd_stat_ctx *ctx, if (processed < window_size) { /* Just fill a hashpipe */ - hashpipe[window_size - ++processed].h = cur; - hashpipe[window_size - ++processed].t = token; + ++processed; + hashpipe[window_size - processed].h = cur; + hashpipe[window_size - processed].t = token; } else { /* Shift hashpipe */