diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-04-30 13:26:51 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-04-30 13:26:51 +0100 |
commit | d6643f35d783784911ad2e2ca754bcfed29eb11d (patch) | |
tree | 55554d57d4439e278788a261eb5ad7e5016a1372 /src/classifiers | |
parent | 7e66b3bd08dbca9356013a3777f786076d1dacea (diff) | |
download | rspamd-d6643f35d783784911ad2e2ca754bcfed29eb11d.tar.gz rspamd-d6643f35d783784911ad2e2ca754bcfed29eb11d.zip |
Refactor config API.
Diffstat (limited to 'src/classifiers')
-rw-r--r-- | src/classifiers/bayes.c | 16 | ||||
-rw-r--r-- | src/classifiers/classifiers.h | 10 | ||||
-rw-r--r-- | src/classifiers/winnow.c | 8 |
3 files changed, 17 insertions, 17 deletions
diff --git a/src/classifiers/bayes.c b/src/classifiers/bayes.c index 9c81b2370..a8a18f5ff 100644 --- a/src/classifiers/bayes.c +++ b/src/classifiers/bayes.c @@ -45,7 +45,7 @@ struct bayes_statfile_data { guint64 hits; guint64 total_hits; double value; - struct statfile *st; + struct rspamd_statfile_config *st; stat_file_t *file; }; @@ -190,7 +190,7 @@ bayes_classify_callback (gpointer key, gpointer value, gpointer data) } struct classifier_ctx* -bayes_init (rspamd_mempool_t *pool, struct classifier_config *cfg) +bayes_init (rspamd_mempool_t *pool, struct rspamd_classifier_config *cfg) { struct classifier_ctx *ctx = rspamd_mempool_alloc (pool, sizeof (struct classifier_ctx)); @@ -210,7 +210,7 @@ bayes_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, gint minnodes; guint64 maxhits = 0, rev; double final_prob, h, s; - struct statfile *st; + struct rspamd_statfile_config *st; stat_file_t *file; GList *cur; char *sumbuf; @@ -249,7 +249,7 @@ bayes_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, data.total_ham = 0; data.total_spam = 0; if (ctx->cfg->opts && (value = g_hash_table_lookup (ctx->cfg->opts, "max_tokens")) != NULL) { - minnodes = parse_limit (value, -1); + minnodes = rspamd_config_parse_limit (value, -1); data.max_tokens = minnodes; } else { @@ -334,7 +334,7 @@ bayes_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, const char *symb gchar *value; gint nodes; gint minnodes; - struct statfile *st, *sel_st = NULL; + struct rspamd_statfile_config *st, *sel_st = NULL; stat_file_t *to_learn; GList *cur; @@ -366,7 +366,7 @@ bayes_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, const char *symb data.processed_tokens = 0; data.processed_tokens = 0; if (ctx->cfg->opts && (value = g_hash_table_lookup (ctx->cfg->opts, "max_tokens")) != NULL) { - minnodes = parse_limit (value, -1); + minnodes = rspamd_config_parse_limit (value, -1); data.max_tokens = minnodes; } else { @@ -434,7 +434,7 @@ bayes_learn_spam (struct classifier_ctx* ctx, statfile_pool_t *pool, gchar *value; gint nodes; gint minnodes; - struct statfile *st; + struct rspamd_statfile_config *st; stat_file_t *file; GList *cur; gboolean skip_labels; @@ -476,7 +476,7 @@ bayes_learn_spam (struct classifier_ctx* ctx, statfile_pool_t *pool, data.processed_tokens = 0; if (ctx->cfg->opts && (value = g_hash_table_lookup (ctx->cfg->opts, "max_tokens")) != NULL) { - minnodes = parse_limit (value, -1); + minnodes = rspamd_config_parse_limit (value, -1); data.max_tokens = minnodes; } else { diff --git a/src/classifiers/classifiers.h b/src/classifiers/classifiers.h index 3f7b755f4..2b36d8c02 100644 --- a/src/classifiers/classifiers.h +++ b/src/classifiers/classifiers.h @@ -10,14 +10,14 @@ /* Consider this value as 0 */ #define ALPHA 0.0001 -struct classifier_config; +struct rspamd_classifier_config; struct rspamd_task; struct classifier_ctx { rspamd_mempool_t *pool; GHashTable *results; gboolean debug; - struct classifier_config *cfg; + struct rspamd_classifier_config *cfg; }; struct classify_weight { @@ -28,7 +28,7 @@ struct classify_weight { /* Common classifier structure */ struct classifier { char *name; - struct classifier_ctx* (*init_func)(rspamd_mempool_t *pool, struct classifier_config *cf); + struct classifier_ctx* (*init_func)(rspamd_mempool_t *pool, struct rspamd_classifier_config *cf); gboolean (*classify_func)(struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct rspamd_task *task, lua_State *L); gboolean (*learn_func)(struct classifier_ctx* ctx, statfile_pool_t *pool, const char *symbol, GTree *input, gboolean in_class, @@ -42,7 +42,7 @@ struct classifier { struct classifier* get_classifier (const char *name); /* Winnow algorithm */ -struct classifier_ctx* winnow_init (rspamd_mempool_t *pool, struct classifier_config *cf); +struct classifier_ctx* winnow_init (rspamd_mempool_t *pool, struct rspamd_classifier_config *cf); gboolean winnow_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct rspamd_task *task, lua_State *L); gboolean winnow_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, const char *symbol, GTree *input, gboolean in_class, double *sum, double multiplier, GError **err); @@ -51,7 +51,7 @@ gboolean winnow_learn_spam (struct classifier_ctx* ctx, statfile_pool_t *pool, GList *winnow_weights (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct rspamd_task *task); /* Bayes algorithm */ -struct classifier_ctx* bayes_init (rspamd_mempool_t *pool, struct classifier_config *cf); +struct classifier_ctx* bayes_init (rspamd_mempool_t *pool, struct rspamd_classifier_config *cf); gboolean bayes_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct rspamd_task *task, lua_State *L); gboolean bayes_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, const char *symbol, GTree *input, gboolean in_class, double *sum, double multiplier, GError **err); diff --git a/src/classifiers/winnow.c b/src/classifiers/winnow.c index 91d06aaf4..1fe8f16d2 100644 --- a/src/classifiers/winnow.c +++ b/src/classifiers/winnow.c @@ -182,7 +182,7 @@ winnow_learn_callback (gpointer key, gpointer value, gpointer data) } struct classifier_ctx * -winnow_init (rspamd_mempool_t * pool, struct classifier_config *cfg) +winnow_init (rspamd_mempool_t * pool, struct rspamd_classifier_config *cfg) { struct classifier_ctx *ctx = rspamd_mempool_alloc (pool, sizeof (struct classifier_ctx)); @@ -199,7 +199,7 @@ winnow_classify (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * inp char *sumbuf, *value; long double res = 0., max = 0.; GList *cur; - struct statfile *st, *sel = NULL; + struct rspamd_statfile_config *st, *sel = NULL; int nodes, minnodes; g_assert (pool != NULL); @@ -287,7 +287,7 @@ winnow_weights (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * inpu struct winnow_callback_data data; long double res = 0.; GList *cur, *resl = NULL; - struct statfile *st; + struct rspamd_statfile_config *st; struct classify_weight *w; char *value; int nodes, minnodes; @@ -360,7 +360,7 @@ winnow_learn (struct classifier_ctx *ctx, statfile_pool_t *pool, const char *sym }; char *value; int nodes, minnodes, iterations = 0; - struct statfile *st, *sel_st = NULL; + struct rspamd_statfile_config *st, *sel_st = NULL; stat_file_t *sel = NULL, *to_learn; long double res = 0., max = 0., start_value = 0., end_value = 0.; double learn_threshold = 0.0; |