]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Some fixes for displaying tokens info
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 31 Mar 2017 16:19:29 +0000 (17:19 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 31 Mar 2017 16:19:29 +0000 (17:19 +0100)
src/libstat/classifiers/bayes.c
src/libstat/tokenizers/osb.c

index 730581ced606f23196c8d84c68eafac6ee13cfcf..aa6899d06d55b83877dc29e08a048385d773c51c 100644 (file)
@@ -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);
+               }
        }
 }
 
index 7c8da26f38fae186523b956fb7da8cfcf0cdeb7c..8d1742cc189d61477ca75fd3db2f1faa1ca58ac3 100644 (file)
@@ -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 */