From 1cd47abf8c71d4af4f761e50e41a8f4a8d67ff0d Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 3 Jan 2021 08:41:29 +0100 Subject: [PATCH] Classifier logging --- .../java/eu/faircode/email/MessageClassifier.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/MessageClassifier.java b/app/src/main/java/eu/faircode/email/MessageClassifier.java index e37c83dcf3..c1ecfe5482 100644 --- a/app/src/main/java/eu/faircode/email/MessageClassifier.java +++ b/app/src/main/java/eu/faircode/email/MessageClassifier.java @@ -36,6 +36,7 @@ import java.text.BreakIterator; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -95,7 +96,14 @@ public class MessageClassifier { if (!wordClassFrequency.containsKey(account.id)) wordClassFrequency.put(account.id, new HashMap<>()); - String classified = classify(account.id, folder.name, text, target == null); + String classified = classify(account.id, folder.name, text, target == null, context); + + EntityLog.log(context, "Classifier" + + " folder=" + folder.name + + " message=" + message.id + + "@" + new Date(message.received) + + ":" + message.subject + + " class=" + classified); Integer m = classMessages.get(account.id).get(folder.name); if (target == null) { @@ -116,7 +124,7 @@ public class MessageClassifier { } } - private static String classify(long account, String classify, String text, boolean added) { + private static String classify(long account, String classify, String text, boolean added, Context context) { int maxFrequency = 0; int maxMatchedWords = 0; List words = new ArrayList<>(); @@ -197,7 +205,7 @@ public class MessageClassifier { Stat stat = classStats.get(clazz); double chance = ((double) stat.totalFrequency / maxFrequency / maxMatchedWords); Chance c = new Chance(clazz, chance); - Log.i("Classifier " + c + + EntityLog.log(context, "Classifier " + c + " frequency=" + stat.totalFrequency + "/" + maxFrequency + " matched=" + stat.matchedWords + "/" + maxMatchedWords); chances.add(c);