diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-30 15:51:08 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-30 15:51:08 +0100 |
commit | 07483bda3b8e29d99c4a70bca70fa1f08c0a574b (patch) | |
tree | cc9fa3c44448b01c0d4a1ed4a9a35d251ba047b9 /conf/statistic.conf | |
parent | 9806fa5b247edaafe0a541639c347504c2b19890 (diff) | |
download | rspamd-07483bda3b8e29d99c4a70bca70fa1f08c0a574b.tar.gz rspamd-07483bda3b8e29d99c4a70bca70fa1f08c0a574b.zip |
[Feature] Add learn condition to the default configuration
Diffstat (limited to 'conf/statistic.conf')
-rw-r--r-- | conf/statistic.conf | 67 |
1 files changed, 47 insertions, 20 deletions
diff --git a/conf/statistic.conf b/conf/statistic.conf index 697f1ccef..e574d0027 100644 --- a/conf/statistic.conf +++ b/conf/statistic.conf @@ -20,27 +20,54 @@ # http://rspamd.com/rspamd_statistics/bayes.ham.sqlite classifier "bayes" { - tokenizer { - name = "osb"; - } - cache { - path = "${DBDIR}/learn_cache.sqlite"; - } - min_tokens = 11; - backend = "sqlite3"; - languages_enabled = true; - min_learns = 200; + tokenizer { + name = "osb"; + } + cache { + path = "${DBDIR}/learn_cache.sqlite"; + } + min_tokens = 11; + backend = "sqlite3"; + languages_enabled = true; + min_learns = 200; - statfile { - symbol = "BAYES_HAM"; - path = "${DBDIR}/bayes.ham.sqlite"; - spam = false; - } - statfile { - symbol = "BAYES_SPAM"; - path = "${DBDIR}/bayes.spam.sqlite"; - spam = true; - } + statfile { + symbol = "BAYES_HAM"; + path = "${DBDIR}/bayes.ham.sqlite"; + spam = false; + } + statfile { + symbol = "BAYES_SPAM"; + path = "${DBDIR}/bayes.spam.sqlite"; + spam = true; + } + learn_condition =<<EOD +return function(task, is_spam, is_unlearn) + local prob = task:get_mempool():get_variable('bayes_prob', 'double') + + if prob then + local in_class = false + local cl + if is_spam then + cl = 'spam' + in_class = prob >= 0.9 + else + cl = 'ham' + in_class = prob <= 0.1 + end + + if is_unlearn and (not in_class) then + return false,string.format('not in class %s; probability %.2f%%', + cl, math.abs((prob - 0.5) * 200.0)) + elseif (not is_unlearn) and in_class then + return false,string.format('already in class %s; probability %.2f%%', + cl, math.abs((prob - 0.5) * 200.0)) + end + end + + return true +end +EOD } .include(try=true; priority=1) "$LOCAL_CONFDIR/local.d/statistic.conf" |