aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-08-01 08:05:06 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-08-01 08:05:06 +0100
commit6dbe8d02d8666d701cc19fa15fa53795260bbd15 (patch)
tree512e13fa63873e24299c5595f882810181cbf080 /src/plugins
parent12bdbf8bc984ca020ad9bd578de24c70d59c98bd (diff)
downloadrspamd-6dbe8d02d8666d701cc19fa15fa53795260bbd15.tar.gz
rspamd-6dbe8d02d8666d701cc19fa15fa53795260bbd15.zip
[Feature] Implement manual ANN train mode
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/lua/fann_redis.lua29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/plugins/lua/fann_redis.lua b/src/plugins/lua/fann_redis.lua
index 65d354b21..2ae9c19d8 100644
--- a/src/plugins/lua/fann_redis.lua
+++ b/src/plugins/lua/fann_redis.lua
@@ -456,15 +456,28 @@ local function fann_train_callback(rule, task, score, required_score, id)
local learn_spam, learn_ham
- if train_opts['spam_score'] then
- learn_spam = score >= train_opts['spam_score']
- else
- learn_spam = score >= required_score
- end
- if train_opts['ham_score'] then
- learn_ham = score <= train_opts['ham_score']
+ if rule.autotrain then
+ if train_opts['spam_score'] then
+ learn_spam = score >= train_opts['spam_score']
+ else
+ learn_spam = score >= required_score
+ end
+ if train_opts['ham_score'] then
+ learn_ham = score <= train_opts['ham_score']
+ else
+ learn_ham = score < 0
+ end
else
- learn_ham = score < 0
+ -- Train by request header
+ local hdr = task:get_request_header('ANN-Train')
+
+ if hdr then
+ if hdr:lower() == 'spam' then
+ learn_spam = true
+ elseif hdr:lower() == 'ham' then
+ learn_ham = true
+ end
+ end
end
if learn_spam or learn_ham then