aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstat/classifiers/classifiers.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-01-23 13:50:17 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-01-23 13:50:17 +0000
commit8a05515078bc8fd3d642778fcae0d005a38ec7b0 (patch)
tree239d86bbbb5ba6bafdfa6aeaa41e848dcdc46079 /src/libstat/classifiers/classifiers.h
parent8f5509c65dc6907a7581518246a200236088423c (diff)
downloadrspamd-8a05515078bc8fd3d642778fcae0d005a38ec7b0.tar.gz
rspamd-8a05515078bc8fd3d642778fcae0d005a38ec7b0.zip
Reorganize libstat API.
Diffstat (limited to 'src/libstat/classifiers/classifiers.h')
-rw-r--r--src/libstat/classifiers/classifiers.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/libstat/classifiers/classifiers.h b/src/libstat/classifiers/classifiers.h
new file mode 100644
index 000000000..4ae1ba23d
--- /dev/null
+++ b/src/libstat/classifiers/classifiers.h
@@ -0,0 +1,49 @@
+#ifndef CLASSIFIERS_H
+#define CLASSIFIERS_H
+
+#include "config.h"
+
+/* Consider this value as 0 */
+#define ALPHA 0.0001
+
+struct rspamd_classifier_config;
+struct rspamd_task;
+
+/* Common classifier structure */
+struct classifier_ctx {
+ rspamd_mempool_t *pool;
+ GHashTable *results;
+ gboolean debug;
+ struct rspamd_classifier_config *cfg;
+};
+
+struct classifier {
+ char *name;
+ struct classifier_ctx * (*init_func)(rspamd_mempool_t *pool,
+ struct rspamd_classifier_config *cf);
+ gboolean (*classify_func)(struct classifier_ctx * ctx,
+ GTree *input, struct rspamd_task *task,
+ lua_State *L);
+ gboolean (*learn_spam_func)(struct classifier_ctx * ctx,
+ GTree *input, struct rspamd_task *task, gboolean is_spam, lua_State *L,
+ GError **err);
+};
+
+/* Bayes algorithm */
+struct classifier_ctx * bayes_init (rspamd_mempool_t *pool,
+ struct rspamd_classifier_config *cf);
+gboolean bayes_classify (struct classifier_ctx * ctx,
+ GTree *input,
+ struct rspamd_task *task,
+ lua_State *L);
+gboolean bayes_learn_spam (struct classifier_ctx * ctx,
+ GTree *input,
+ struct rspamd_task *task,
+ gboolean is_spam,
+ lua_State *L,
+ GError **err);
+
+#endif
+/*
+ * vi:ts=4
+ */