From: Alexander Moisseev Date: Mon, 16 Apr 2018 08:04:14 +0000 (+0300) Subject: [Minor] Discriminate infrequent common tokens as well X-Git-Tag: 1.7.4~96^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F2176%2Fhead;p=thirdparty%2Frspamd.git [Minor] Discriminate infrequent common tokens as well --- diff --git a/src/plugins/lua/bayes_expiry.lua b/src/plugins/lua/bayes_expiry.lua index ea7ae1a9fa..aeedf5f173 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