aboutsummaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authoraduernberger <aduernberger@googlemail.com>2024-04-18 14:44:01 +0200
committerGitHub <noreply@github.com>2024-04-18 14:44:01 +0200
commit26f96b81fdf73a0bd4a663837ea4df496dcbbc14 (patch)
tree69a14af2e0d43d5aa2385e0ece57dbcdf5c75928 /lualib
parentccc1716bb546423aa9e1eaee19fb470c2ec2fa45 (diff)
downloadrspamd-26f96b81fdf73a0bd4a663837ea4df496dcbbc14.tar.gz
rspamd-26f96b81fdf73a0bd4a663837ea4df496dcbbc14.zip
[Fix] Increase/decrease hash_key value for tokens depending on is_unlearn
When relearning a message, this script is called twice: 1. With `is_unlearn` true and the old `is_spam` value 2. With `is_unlearn` false and the new `is_spam` value If `is_unlearn` is true, the code should not increase the value of the hash_key. Decreasing it ensures that it behaves like a fresh learn with the new is_spam value.
Diffstat (limited to 'lualib')
-rw-r--r--lualib/redis_scripts/bayes_learn.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/lualib/redis_scripts/bayes_learn.lua b/lualib/redis_scripts/bayes_learn.lua
index 80d86d803..5456165b6 100644
--- a/lualib/redis_scripts/bayes_learn.lua
+++ b/lualib/redis_scripts/bayes_learn.lua
@@ -26,7 +26,7 @@ redis.call('HSET', prefix, 'version', '2') -- new schema
redis.call('HINCRBY', prefix, learned_key, is_unlearn and -1 or 1) -- increase or decrease learned count
for i, token in ipairs(input_tokens) do
- redis.call('HINCRBY', token, hash_key, 1)
+ redis.call('HINCRBY', token, hash_key, is_unlearn and -1 or 1)
if text_tokens then
local tok1 = text_tokens[i * 2 - 1]
local tok2 = text_tokens[i * 2]
@@ -41,4 +41,4 @@ for i, token in ipairs(input_tokens) do
redis.call('ZINCRBY', prefix .. '_z', is_unlearn and -1 or 1, token)
end
end
-end \ No newline at end of file
+end