diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-01-29 17:46:26 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-01-29 17:46:26 +0300 |
commit | 32a96e82d075bdba6e9e567080977a76830cbce2 (patch) | |
tree | 028ebfd9118e5c9d33c07593eef7ea4c8b37108e /src/controller.c | |
parent | 24e7403974f65b788ad81071d30c092adde97f4e (diff) | |
download | rspamd-32a96e82d075bdba6e9e567080977a76830cbce2.tar.gz rspamd-32a96e82d075bdba6e9e567080977a76830cbce2.zip |
* Do another rework of filters/metrics and statfiles processing
* Add 'probability' normalizing to winnow algorithm and calculate not pure weight but normalized probability
Diffstat (limited to 'src/controller.c')
-rw-r--r-- | src/controller.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/controller.c b/src/controller.c index 8a3377c44..104b8d7ca 100644 --- a/src/controller.c +++ b/src/controller.c @@ -140,6 +140,7 @@ process_command (struct controller_command *cmd, char **cmd_args, struct control time_t uptime; unsigned long size = 0; struct statfile *statfile; + struct metric *metric; memory_pool_stat_t mem_st; switch (cmd->type) { @@ -270,11 +271,19 @@ process_command (struct controller_command *cmd, char **cmd_args, struct control return; } + + metric = g_hash_table_lookup (session->cfg->metrics, statfile->metric); + session->learn_rcpt = NULL; session->learn_from = NULL; session->learn_filename = NULL; session->learn_tokenizer = statfile->tokenizer; - session->learn_classifier = statfile->classifier; + if (metric != NULL) { + session->learn_classifier = metric->classifier; + } + else { + session->learn_classifier = get_classifier ("winnow"); + } /* By default learn positive */ session->in_class = 1; /* Get all arguments */ @@ -348,6 +357,7 @@ static void read_socket (struct bufferevent *bev, void *arg) { struct controller_session *session = (struct controller_session *)arg; + struct classifier_ctx *cls_ctx; int len, i; char *s, **params, *cmd, out_buf[128]; GList *comp_list, *cur = NULL; @@ -424,7 +434,9 @@ read_socket (struct bufferevent *bev, void *arg) return; } } - session->learn_classifier->learn_func (session->worker->srv->statfile_pool, session->learn_filename, tokens, session->in_class); + cls_ctx = session->learn_classifier->init_func (session->session_pool); + session->learn_classifier->learn_func (cls_ctx, session->worker->srv->statfile_pool, + session->learn_filename, tokens, session->in_class); session->worker->srv->stat->messages_learned ++; i = snprintf (out_buf, sizeof (out_buf), "learn ok" CRLF); bufferevent_write (bev, out_buf, i); |