diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-12-30 21:37:42 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-12-31 07:08:19 +0000 |
commit | 6d0cfe35ab90a19e932184d301d726d52248f09d (patch) | |
tree | 4b107e20167d2dce0d61e64ed4ad3f40f4181f05 /lualib | |
parent | 38244b721b4ee82431c95cad69bac97dd54d44cc (diff) | |
download | rspamd-6d0cfe35ab90a19e932184d301d726d52248f09d.tar.gz rspamd-6d0cfe35ab90a19e932184d301d726d52248f09d.zip |
[Project] Implement text tokens storage on C++ side
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/redis_scripts/bayes_learn.lua | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lualib/redis_scripts/bayes_learn.lua b/lualib/redis_scripts/bayes_learn.lua index b0ed1dd4b..bf2775349 100644 --- a/lualib/redis_scripts/bayes_learn.lua +++ b/lualib/redis_scripts/bayes_learn.lua @@ -31,12 +31,14 @@ for i, token in ipairs(input_tokens) do local tok1 = text_tokens[i * 2 - 1] local tok2 = text_tokens[i * 2] - if tok2 then - redis.call('HSET', token, 'tokens', string.format('%s:%s', tok1, tok2)) - else - redis.call('HSET', token, 'tokens', tok1) - end + if tok1 then + if tok2 then + redis.call('HSET', token, 'tokens', string.format('%s:%s', tok1, tok2)) + else + redis.call('HSET', token, 'tokens', tok1) + end - redis.call('ZINCRBY', prefix .. '_z', token, is_unlearn and -1 or 1) + redis.call('ZINCRBY', prefix .. '_z', token, is_unlearn and -1 or 1) + end end end
\ No newline at end of file |