diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-09-02 20:02:50 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-09-02 20:02:50 +0100 |
commit | 905820d0d3f92b0861189441f03a908b0ea14a55 (patch) | |
tree | d33377d956fdc343a74a2f05a038e3acf22c8003 /src/lua/lua_task.c | |
parent | 7d236456e6bc91fe10eaa597bc1dfe3d141a0ccd (diff) | |
download | rspamd-905820d0d3f92b0861189441f03a908b0ea14a55.tar.gz rspamd-905820d0d3f92b0861189441f03a908b0ea14a55.zip |
[Rework] Start moving of fann redis to torch
Diffstat (limited to 'src/lua/lua_task.c')
-rw-r--r-- | src/lua/lua_task.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 61ef6d075..9d139044f 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -3134,6 +3134,7 @@ struct tokens_foreach_cbdata { struct rspamd_task *task; lua_State *L; gint idx; + gboolean normalize; }; static void @@ -3150,7 +3151,12 @@ tokens_foreach_cb (gint id, const gchar *sym, gint flags, gpointer ud) mres = cbd->task->result; if (mres && (s = g_hash_table_lookup (mres->symbols, sym)) != NULL) { - lua_pushnumber (cbd->L, tanh (s->score)); + if (cbd->normalize) { + lua_pushnumber (cbd->L, tanh (s->score)); + } + else { + lua_pushnumber (cbd->L, s->score); + } } else { lua_pushnumber (cbd->L, 0.0); @@ -3168,6 +3174,15 @@ lua_task_get_symbols_tokens (lua_State *L) cbd.task = task; cbd.L = L; cbd.idx = 1; + cbd.normalize = TRUE; + + if (lua_type (L, 2) == LUA_TBOOLEAN) { + cbd.normalize = lua_toboolean (L, 2); + } + else { + cbd.normalize = TRUE; + } + lua_createtable (L, rspamd_symbols_cache_symbols_count (task->cfg->cache), 0); rspamd_symbols_cache_foreach (task->cfg->cache, tokens_foreach_cb, &cbd); |