diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-27 16:05:15 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-27 16:05:15 +0100 |
commit | 1ed9f282a568ef64372f687dba5ca25033b0ce2b (patch) | |
tree | af29263bf46da3c936cb1c9c0aa4743f9e736438 /rules | |
parent | 781af3209968da2b8d7a4b1e38d4a1473c8a9852 (diff) | |
download | rspamd-1ed9f282a568ef64372f687dba5ca25033b0ce2b.tar.gz rspamd-1ed9f282a568ef64372f687dba5ca25033b0ce2b.zip |
[Fix] Fix and rescore R_PARTS_DIFFER logic
Signed-off-by: Vsevolod Stakhov <vsevolod@highsecure.ru>
Diffstat (limited to 'rules')
-rw-r--r-- | rules/misc.lua | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/rules/misc.lua b/rules/misc.lua index 9bd6b85f6..7bfe73551 100644 --- a/rules/misc.lua +++ b/rules/misc.lua @@ -33,15 +33,24 @@ reconf['R_FLASH_REDIR_IMGSHACK'] = '/^(?:http:\\/\\/)?img\\d{1,5}\\.imageshack\\ -- Different text parts rspamd_config.R_PARTS_DIFFER = function(task) - local distance = task:get_mempool():get_variable('parts_distance', 'int') + local distance = task:get_mempool():get_variable('parts_distance', 'double') if distance then local nd = tonumber(distance) - - if nd < 50 then - local score = 1 - util.tanh(nd / 100.0) - - task:insert_result('R_PARTS_DIFFER', score, tostring(nd) .. '%') + -- ND is relation of different words to total words + if nd >= 0.5 then + local tw = task:get_mempool():get_variable('total_words', 'int') + + if tw then + if tw > 30 then + -- We are confident about difference + local score = (nd - 0.5) * 2.0 + else + -- We are not so confident about difference + local score = (nd - 0.5) + end + task:insert_result('R_PARTS_DIFFER', score, tostring(100.0 * nd) .. '%') + end end end |