summaryrefslogtreecommitdiffstats
path: root/src/libstat/classifiers
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-01-06 14:24:07 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-01-06 14:24:07 +0000
commitdf9ada40a53a804d2d90d9dfddc149a68c141a15 (patch)
treeecf56c7cf18b8a95b2fc6a38933ea7dd142c432b /src/libstat/classifiers
parent1622570f58b5f5b184f97cd75a52a98cc0b1721a (diff)
downloadrspamd-df9ada40a53a804d2d90d9dfddc149a68c141a15.tar.gz
rspamd-df9ada40a53a804d2d90d9dfddc149a68c141a15.zip
Add learning implementation.
Diffstat (limited to 'src/libstat/classifiers')
-rw-r--r--src/libstat/classifiers/bayes.c5
-rw-r--r--src/libstat/classifiers/classifiers.h5
2 files changed, 7 insertions, 3 deletions
diff --git a/src/libstat/classifiers/bayes.c b/src/libstat/classifiers/bayes.c
index 0915933f1..b08c70380 100644
--- a/src/libstat/classifiers/bayes.c
+++ b/src/libstat/classifiers/bayes.c
@@ -303,6 +303,7 @@ bayes_learn_spam (struct rspamd_classifier * ctx,
GPtrArray *tokens,
struct rspamd_task *task,
gboolean is_spam,
+ gboolean unlearn,
GError **err)
{
guint i, j;
@@ -325,7 +326,7 @@ bayes_learn_spam (struct rspamd_classifier * ctx,
if (st->stcf->is_spam) {
tok->values[id]++;
}
- else if (tok->values[id] > 0) {
+ else if (tok->values[id] > 0 && unlearn) {
/* Unlearning */
tok->values[id]--;
}
@@ -334,7 +335,7 @@ bayes_learn_spam (struct rspamd_classifier * ctx,
if (!st->stcf->is_spam) {
tok->values[id]++;
}
- else if (tok->values[id] > 0) {
+ else if (tok->values[id] > 0 && unlearn) {
/* Unlearning */
tok->values[id]--;
}
diff --git a/src/libstat/classifiers/classifiers.h b/src/libstat/classifiers/classifiers.h
index 86395c96d..6bafa8507 100644
--- a/src/libstat/classifiers/classifiers.h
+++ b/src/libstat/classifiers/classifiers.h
@@ -23,7 +23,9 @@ struct rspamd_stat_classifier {
struct rspamd_task *task);
gboolean (*learn_spam_func)(struct rspamd_classifier * ctx,
GPtrArray *input,
- struct rspamd_task *task, gboolean is_spam,
+ struct rspamd_task *task,
+ gboolean is_spam,
+ gboolean unlearn,
GError **err);
};
@@ -37,6 +39,7 @@ gboolean bayes_learn_spam (struct rspamd_classifier *ctx,
GPtrArray *tokens,
struct rspamd_task *task,
gboolean is_spam,
+ gboolean unlearn,
GError **err);
#endif