]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Allow to specify spam/ham symbols in classifier_test
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 28 Jun 2024 14:21:23 +0000 (15:21 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 28 Jun 2024 14:21:23 +0000 (15:21 +0100)
lualib/rspamadm/classifier_test.lua

index 21af14fc1748ff6df567253477b2552a6c9ed22c..4e001bf17e24d16f98301c06991ae5d24f449984 100644 (file)
@@ -40,6 +40,14 @@ parser:option "-c --cv-fraction"
       :argname("<fraction>")
       :convert(tonumber)
       :default('0.7')
+parser:option "--spam-symbol"
+      :description("Use specific spam symbol (instead of BAYES_SPAM)")
+      :argname("<symbol>")
+      :default('BAYES_SPAM')
+parser:option "--ham-symbol"
+      :description("Use specific ham symbol (instead of BAYES_HAM)")
+      :argname("<symbol>")
+      :default('BAYES_HAM')
 
 local opts
 
@@ -86,7 +94,8 @@ local function classify_files(files)
   local fname = os.tmpname()
   list_to_file(files, fname)
 
-  local settings_header = '--header Settings=\"{symbols_enabled=[BAYES_SPAM, BAYES_HAM]}\"'
+  local settings_header = string.format('--header Settings=\"{symbols_enabled=[%s, %s]}\"',
+      opts.spam_symbol, opts.ham_symbol)
   local rspamc_command = string.format("%s %s --connect %s --compact -n %s -t %.3f --files-list=%s",
       opts.rspamc,
       settings_header,
@@ -107,9 +116,9 @@ local function classify_files(files)
     local file = obj.filename
     local symbols = obj.symbols or {}
 
-    if symbols["BAYES_SPAM"] then
+    if symbols[opts.spam_symbol] then
       table.insert(results, { result = "spam", file = file })
-    elseif symbols["BAYES_HAM"] then
+    elseif symbols[opts.ham_symbol] then
       table.insert(results, { result = "ham", file = file })
     end
   end