Added/tuned further constants

master
Thor 3 years ago
parent c0df23f0b9
commit 36b974185c
  1. 12
      bogofilter.py

@ -3,8 +3,14 @@ from email.utils import format_datetime
from datetime import datetime
import quopri
BOGOFILTER_DB_DIR = "."
BOGOFILTER_COMMAND = ["bogofilter", "-T", "-c", "/dev/null", "-d", BOGOFILTER_DB_DIR, "-o", "0.25,0.07"]
DB_DIR = "."
MAX_HAM = 0.07
MIN_SPAM = 0.25
MIN_DEV = 2 * (MIN_SPAM - MAX_HAM) * 0.375
ROBS = 0.0178
ROBX = (MAX_HAM + MIN_SPAM) / 2
COMMAND = ["bogofilter", "-T", "-c", "/dev/null", "-d", DB_DIR, "-o", "{},{}".format(MIN_SPAM, MAX_HAM), "-m", "{},{},{}".format(MIN_DEV, ROBS, ROBX)]
# Categories
SPAM = "S"
@ -70,7 +76,7 @@ def run(text, actions = [CLASSIFY], category = UNSURE):
for action in actions:
args.extend(ACTIONS[action])
cp = subprocess.run(BOGOFILTER_COMMAND + args, capture_output = True, encoding = "utf-8", input = text)
cp = subprocess.run(COMMAND + args, capture_output = True, encoding = "utf-8", input = text)
arr = cp.stdout.strip().split(" ")
if len(arr) == 2:
(category, score) = arr

Loading…
Cancel
Save