aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstat/classifiers/bayes.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-01-17 21:59:44 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-01-18 23:05:15 +0000
commiteb9ae27c70a0b3030e6302cc065485f798a05e82 (patch)
tree52ebdd99c677cd8c50b977bcb2cd47fa4a16cd3f /src/libstat/classifiers/bayes.c
parent665166c376a54f52b070e891780ca6209bbaa2d1 (diff)
downloadrspamd-eb9ae27c70a0b3030e6302cc065485f798a05e82.tar.gz
rspamd-eb9ae27c70a0b3030e6302cc065485f798a05e82.zip
Remove old statfile_pool logic.
Diffstat (limited to 'src/libstat/classifiers/bayes.c')
-rw-r--r--src/libstat/classifiers/bayes.c126
1 files changed, 0 insertions, 126 deletions
diff --git a/src/libstat/classifiers/bayes.c b/src/libstat/classifiers/bayes.c
index d2ecb340e..070f02008 100644
--- a/src/libstat/classifiers/bayes.c
+++ b/src/libstat/classifiers/bayes.c
@@ -357,122 +357,6 @@ bayes_classify (struct classifier_ctx * ctx,
}
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)
-{
- struct bayes_callback_data data;
- gchar *value;
- gint nodes;
- gint minnodes;
- struct rspamd_statfile_config *st, *sel_st = NULL;
- stat_file_t *to_learn;
- GList *cur;
-
- g_assert (pool != NULL);
- g_assert (ctx != NULL);
-
- if (ctx->cfg->opts &&
- (value = g_hash_table_lookup (ctx->cfg->opts, "min_tokens")) != NULL) {
- minnodes = strtol (value, NULL, 10);
- nodes = g_tree_nnodes (input);
- if (nodes > FEATURE_WINDOW_SIZE) {
- nodes = nodes / FEATURE_WINDOW_SIZE + FEATURE_WINDOW_SIZE;
- }
- if (nodes < minnodes) {
- msg_info (
- "do not learn message as it has too few tokens: %d, while %d min",
- nodes,
- minnodes);
- *sum = 0;
- g_set_error (err,
- bayes_error_quark (), /* error domain */
- 1, /* error code */
- "message contains too few tokens: %d, while min is %d",
- nodes, (int)minnodes);
- return FALSE;
- }
- }
-
- data.pool = pool;
- data.in_class = in_class;
- data.now = time (NULL);
- data.ctx = ctx;
- data.processed_tokens = 0;
- data.processed_tokens = 0;
- if (ctx->cfg->opts &&
- (value = g_hash_table_lookup (ctx->cfg->opts, "max_tokens")) != NULL) {
- minnodes = rspamd_config_parse_limit (value, -1);
- data.max_tokens = minnodes;
- }
- else {
- data.max_tokens = 0;
- }
- cur = ctx->cfg->statfiles;
- while (cur) {
- /* Select statfile to learn */
- st = cur->data;
- if (strcmp (st->symbol, symbol) == 0) {
- sel_st = st;
- break;
- }
- cur = g_list_next (cur);
- }
- if (sel_st == NULL) {
- g_set_error (err,
- bayes_error_quark (), /* error domain */
- 1, /* error code */
- "cannot find statfile for symbol: %s",
- symbol);
- return FALSE;
- }
- if ((to_learn = statfile_pool_is_open (pool, sel_st->path)) == NULL) {
- if ((to_learn =
- statfile_pool_open (pool, sel_st->path, sel_st->size,
- FALSE)) == NULL) {
- msg_warn ("cannot open %s", sel_st->path);
- if (statfile_pool_create (pool, sel_st->path, sel_st->size) == -1) {
- msg_err ("cannot create statfile %s", sel_st->path);
- g_set_error (err,
- bayes_error_quark (), /* error domain */
- 1, /* error code */
- "cannot create statfile: %s",
- sel_st->path);
- return FALSE;
- }
- if ((to_learn =
- statfile_pool_open (pool, sel_st->path, sel_st->size,
- FALSE)) == NULL) {
- g_set_error (err,
- bayes_error_quark (), /* error domain */
- 1, /* error code */
- "cannot open statfile %s after creation",
- sel_st->path);
- msg_err ("cannot open statfile %s after creation",
- sel_st->path);
- return FALSE;
- }
- }
- }
- data.file = to_learn;
- statfile_pool_lock_file (pool, data.file);
- g_tree_foreach (input, bayes_learn_callback, &data);
- statfile_inc_revision (to_learn);
- statfile_pool_unlock_file (pool, data.file);
-
- if (sum != NULL) {
- *sum = data.processed_tokens;
- }
-
- return TRUE;
-}
-
-gboolean
bayes_learn_spam (struct classifier_ctx * ctx,
statfile_pool_t *pool,
GTree *input,
@@ -583,13 +467,3 @@ bayes_learn_spam (struct classifier_ctx * ctx,
return TRUE;
}
-
-GList *
-bayes_weights (struct classifier_ctx * ctx,
- statfile_pool_t *pool,
- GTree *input,
- struct rspamd_task *task)
-{
- /* This function is unimplemented with new normalizer */
- return NULL;
-}