diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-04-16 09:18:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-16 09:18:55 +0100 |
commit | 730437924bfc1a20519d45d60dbc5213c0a2d4ab (patch) | |
tree | b1a0eaa19753433b5b74e94789ec682aa5acc01e | |
parent | 2e3751412b1d80d84bf56d426e628978f49eda71 (diff) | |
parent | 00326764e9dc53cf8a96451bf4245b472d273998 (diff) | |
download | rspamd-730437924bfc1a20519d45d60dbc5213c0a2d4ab.tar.gz rspamd-730437924bfc1a20519d45d60dbc5213c0a2d4ab.zip |
Merge pull request #2176 from moisseev/expiry
[Minor] Discriminate infrequent common tokens as well
-rw-r--r-- | src/plugins/lua/bayes_expiry.lua | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/plugins/lua/bayes_expiry.lua b/src/plugins/lua/bayes_expiry.lua index ea7ae1a9f..aeedf5f17 100644 --- a/src/plugins/lua/bayes_expiry.lua +++ b/src/plugins/lua/bayes_expiry.lua @@ -201,7 +201,13 @@ local expiry_script = [[ local threshold = mean local total = spam + ham - if total >= threshold and total > 0 then + if total == 0 or math.abs(ham - spam) <= total * ${epsilon_common} then + common = common + 1 + if ttl > ${common_ttl} then + discriminated = discriminated + 1 + redis.call('EXPIRE', key, ${common_ttl}) + end + elseif total >= threshold and total > 0 then if ham / total > ${significant_factor} or spam / total > ${significant_factor} then significant = significant + 1 if ${lazy} or expire < 0 then @@ -214,12 +220,6 @@ local expiry_script = [[ extended = extended + 1 end end - elseif total == 0 or math.abs(ham - spam) <= total * ${epsilon_common} then - common = common + 1 - if ttl > ${common_ttl} then - discriminated = discriminated + 1 - redis.call('EXPIRE', key, ${common_ttl}) - end else infrequent = infrequent + 1 if expire < 0 then |