diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-01-29 17:46:26 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-01-29 17:46:26 +0300 |
commit | 32a96e82d075bdba6e9e567080977a76830cbce2 (patch) | |
tree | 028ebfd9118e5c9d33c07593eef7ea4c8b37108e /src/classifiers/classifiers.h | |
parent | 24e7403974f65b788ad81071d30c092adde97f4e (diff) | |
download | rspamd-32a96e82d075bdba6e9e567080977a76830cbce2.tar.gz rspamd-32a96e82d075bdba6e9e567080977a76830cbce2.zip |
* Do another rework of filters/metrics and statfiles processing
* Add 'probability' normalizing to winnow algorithm and calculate not pure weight but normalized probability
Diffstat (limited to 'src/classifiers/classifiers.h')
-rw-r--r-- | src/classifiers/classifiers.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/classifiers/classifiers.h b/src/classifiers/classifiers.h index 71a08c684..2a2929b7d 100644 --- a/src/classifiers/classifiers.h +++ b/src/classifiers/classifiers.h @@ -11,20 +11,29 @@ #include "../statfile.h" #include "../tokenizers/tokenizers.h" +struct classifier_ctx { + memory_pool_t *pool; + GHashTable *results; +}; /* Common classifier structure */ struct classifier { char *name; - double (*classify_func)(statfile_pool_t *pool, char *statfile, GTree *input); - void (*learn_func)(statfile_pool_t *pool, char *statfile, GTree *input, int in_class); - double (*add_result_func)(double result, double new); + struct classifier_ctx* (*init_func)(memory_pool_t *pool); + void (*classify_func)(struct classifier_ctx* ctx, statfile_pool_t *pool, + char *statfile, GTree *input, double scale); + void (*learn_func)(struct classifier_ctx* ctx, statfile_pool_t *pool, + char *statfile, GTree *input, int in_class); + char* (*result_file_func)(struct classifier_ctx *ctx, double *probability); }; /* Get classifier structure by name or return NULL if this name is not found */ struct classifier* get_classifier (char *name); + /* Winnow algorithm */ -double winnow_classify (statfile_pool_t *pool, char *statfile, GTree *input); -void winnow_learn (statfile_pool_t *pool, char *statfile, GTree *input, int in_class); -double winnow_add_result (double result, double new); +struct classifier_ctx* winnow_init (memory_pool_t *pool); +void winnow_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, char *statfile, GTree *input, double scale); +void winnow_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, char *statfile, GTree *input, int in_class); +char* winnow_result_file (struct classifier_ctx* ctx, double *probability); /* Array of all defined classifiers */ extern struct classifier classifiers[]; |