aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-09-05 17:18:05 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-09-05 17:18:05 +0100
commitc5dccd9bcd47bf8615f7472b81c7ffa76013a5de (patch)
tree3aabbaf8f087cac07f48aba48584c2c48002b9d2 /src/plugins
parent0a52bb55e954a56fc4d2a934e4d33ee1e77795a0 (diff)
downloadrspamd-c5dccd9bcd47bf8615f7472b81c7ffa76013a5de.tar.gz
rspamd-c5dccd9bcd47bf8615f7472b81c7ffa76013a5de.zip
[Feature] Insert two symbols: FANN_HAM and FANN_SPAM instead of one
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/lua/fann_scores.lua18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/plugins/lua/fann_scores.lua b/src/plugins/lua/fann_scores.lua
index cafa5befa..4d5c9a156 100644
--- a/src/plugins/lua/fann_scores.lua
+++ b/src/plugins/lua/fann_scores.lua
@@ -20,7 +20,8 @@ limitations under the License.
local rspamd_logger = require "rspamd_logger"
local rspamd_fann = require "rspamd_fann"
local rspamd_util = require "rspamd_util"
-local fann_symbol = 'FANN_SCORE'
+local fann_symbol_spam = 'FANN_SPAM'
+local fann_symbol_ham = 'FANN_HAM'
require "fun" ()
local ucl = require "ucl"
@@ -161,7 +162,11 @@ local function fann_scores_filter(task)
local symscore = string.format('%.3f', out[1])
rspamd_logger.infox(task, 'fann score: %s', symscore)
- task:insert_result(fann_symbol, result, symscore, id)
+ if symscore > 0 then
+ task:insert_result(fann_symbol_spam, result, symscore, id)
+ else
+ task:insert_result(fann_symbol_ham, result, -(symscore), id)
+ end
else
if load_fann(id) then
fann_scores_filter(task)
@@ -262,11 +267,16 @@ else
fann_file = opts['fann_file']
use_settings = opts['use_settings']
rspamd_config:set_metric_symbol(fann_symbol, 3.0, 'Experimental FANN adjustment')
- rspamd_config:register_symbol({
- name = fann_symbol,
+ local id = rspamd_config:register_symbol({
+ name = fann_symbol_spam,
type = 'postfilter',
callback = fann_scores_filter
})
+ rspamd_config:register_symbol({
+ name = fann_symbol_ham,
+ type = 'virtual',
+ parent = id
+ })
if opts['train'] then
rspamd_config:add_on_load(function(cfg)
if opts['train']['max_train'] then