From b2e175cd94221695e98806582dd4aafa59ff8a84 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 5 Jan 2021 08:39:26 +0100 Subject: [PATCH] Classifier: use message count instead of max frequency --- .../main/java/eu/faircode/email/MessageClassifier.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/MessageClassifier.java b/app/src/main/java/eu/faircode/email/MessageClassifier.java index 3262616ced..63ddd55383 100644 --- a/app/src/main/java/eu/faircode/email/MessageClassifier.java +++ b/app/src/main/java/eu/faircode/email/MessageClassifier.java @@ -167,7 +167,6 @@ public class MessageClassifier { } private static String classify(long account, String classify, String text, boolean added, Context context) { - int maxFrequency = 0; int maxMatchedWords = 0; List words = new ArrayList<>(); Map classStats = new HashMap<>(); @@ -208,8 +207,6 @@ public class MessageClassifier { for (String clazz : applyClasses) { int frequency = classFrequency.get(clazz); - if (frequency > maxFrequency) - maxFrequency = frequency; Stat stat = classStats.get(clazz); if (stat == null) { @@ -244,11 +241,12 @@ public class MessageClassifier { List chances = new ArrayList<>(); for (String clazz : classStats.keySet()) { + int messages = classMessages.get(account).get(clazz); Stat stat = classStats.get(clazz); - double chance = ((double) stat.totalFrequency / maxFrequency / maxMatchedWords); + double chance = (double) stat.totalFrequency / messages / maxMatchedWords; Chance c = new Chance(clazz, chance); EntityLog.log(context, "Classifier " + c + - " frequency=" + stat.totalFrequency + "/" + maxFrequency + + " frequency=" + stat.totalFrequency + "/" + messages + " matched=" + stat.matchedWords + "/" + maxMatchedWords); chances.add(c); }