From: Vsevolod Stakhov Date: Mon, 5 Sep 2016 16:18:05 +0000 (+0100) Subject: [Feature] Insert two symbols: FANN_HAM and FANN_SPAM instead of one X-Git-Tag: 1.4.0~487 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c5dccd9bcd47bf8615f7472b81c7ffa76013a5de;p=thirdparty%2Frspamd.git [Feature] Insert two symbols: FANN_HAM and FANN_SPAM instead of one --- diff --git a/src/plugins/lua/fann_scores.lua b/src/plugins/lua/fann_scores.lua index cafa5befa7..4d5c9a1567 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