summaryrefslogtreecommitdiffstats
path: root/src/libstat/classifiers/classifiers.h
blob: 6a77f5aed5016216cf34ed0f81db80a65a24da89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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 rspamd_stat_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
 */