From 905820d0d3f92b0861189441f03a908b0ea14a55 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 2 Sep 2017 20:02:50 +0100 Subject: [Rework] Start moving of fann redis to torch --- src/lua/lua_task.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/lua/lua_task.c') 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); -- cgit v1.2.3