Server IP : 104.21.38.3 / Your IP : 162.158.108.160 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/rspamd/lualib/redis_scripts/ |
Upload File : |
-- Lua script to perform bayes classification -- This script accepts the following parameters: -- key1 - prefix for bayes tokens (e.g. for per-user classification) -- key2 - set of tokens encoded in messagepack array of strings local prefix = KEYS[1] local output_spam = {} local output_ham = {} local learned_ham = tonumber(redis.call('HGET', prefix, 'learns_ham')) or 0 local learned_spam = tonumber(redis.call('HGET', prefix, 'learns_spam')) or 0 -- Output is a set of pairs (token_index, token_count), tokens that are not -- found are not filled. -- This optimisation will save a lot of space for sparse tokens, and in Bayes that assumption is normally held if learned_ham > 0 and learned_spam > 0 then local input_tokens = cmsgpack.unpack(KEYS[2]) for i, token in ipairs(input_tokens) do local token_data = redis.call('HMGET', token, 'H', 'S') if token_data then local ham_count = token_data[1] local spam_count = token_data[2] if ham_count then table.insert(output_ham, { i, tonumber(ham_count) }) end if spam_count then table.insert(output_spam, { i, tonumber(spam_count) }) end end end end return { learned_ham, learned_spam, output_ham, output_spam }