]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
* Remove normalizer as it is winnow specific thing, so all statistic algorithms now...
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 13 Aug 2010 15:38:55 +0000 (19:38 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 13 Aug 2010 15:38:55 +0000 (19:38 +0400)
src/cfg_xml.c
src/classifiers/winnow.c
src/controller.c

index 43c4091d1dbfd8f899b46f9546c5a48eb4d4506d..9e86997e0b3687075122d9a832e47b9bea2ae01d 100644 (file)
@@ -1089,13 +1089,7 @@ handle_classifier_opt (struct config_file *cfg, struct rspamd_xml_userdata *ctx,
 gboolean 
 handle_statfile_normalizer (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
 {
-       struct statfile             *st = ctx->section_pointer;
-       
-       if (!parse_normalizer (cfg, st, data)) {
-               msg_err ("cannot parse normalizer string: %s", data);
-               return FALSE;
-       }
-       
+       msg_info ("normalizer option is now not available as rspamd always use internal normalizer for winnow (hyperbolic tanhent)");
        return TRUE;
 }
 
index f8c104a5208ffb054c6dc6ea90779bdd747ba414..c86782d854f8f930bb5c246ebe42d9da6592f756 100644 (file)
@@ -267,9 +267,15 @@ winnow_classify (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * inp
 #ifdef WITH_LUA
         max = call_classifier_post_callbacks (ctx->cfg, task, max);
 #endif
-               if (st->normalizer != NULL) {
-                       max = st->normalizer (task->cfg, max, st->normalizer_data);
-               }
+#ifdef HAVE_TANHL
+        max = tanhl (max);
+#else
+        /*
+         * As some implementations of libm does not support tanhl, try to use
+         * tanh
+         */
+        max = tanh ((double) score);
+#endif
                sumbuf = memory_pool_alloc (task->task_pool, 32);
                rspamd_snprintf (sumbuf, 32, "%.2F", max);
                cur = g_list_prepend (NULL, sumbuf);
@@ -557,7 +563,15 @@ winnow_learn (struct classifier_ctx *ctx, statfile_pool_t *pool, const char *sym
 
 end:
        if (sum) {
-               *sum = (double)max;
+#ifdef HAVE_TANHL
+        *sum = (double)tanhl (max);
+#else
+        /*
+         * As some implementations of libm does not support tanhl, try to use
+         * tanh
+         */
+        *sum = tanh ((double) score);
+#endif
        }
        return TRUE;
 }
index a79159c691a0fbf2c01b35f36b89baea1af6dc8e..f3cdc74deffa23c150cfc5c43dda682dc8431715 100644 (file)
@@ -849,9 +849,6 @@ controller_read_socket (f_str_t * in, void *arg)
                session->worker->srv->stat->messages_learned++;
 
                maybe_write_binlog (session->learn_classifier, st, statfile, tokens);
-               if (st->normalizer != NULL) {
-                       sum = st->normalizer (session->cfg, sum, st->normalizer_data);
-               }
                msg_info ("learn success for message <%s>, for statfile: %s, sum weight: %.2f",
                                task->message_id, session->learn_symbol, sum);
                free_task (task, FALSE);