From f47396938680b1d7587ded2000ca4dd3238ccb7c Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 16 Aug 2021 10:15:26 +0200 Subject: [PATCH] Added classifier log type --- .../java/eu/faircode/email/EntityLog.java | 2 +- .../eu/faircode/email/MessageClassifier.java | 29 ++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/EntityLog.java b/app/src/main/java/eu/faircode/email/EntityLog.java index f8296ff3d0..110a77ed7d 100644 --- a/app/src/main/java/eu/faircode/email/EntityLog.java +++ b/app/src/main/java/eu/faircode/email/EntityLog.java @@ -59,7 +59,7 @@ public class EntityLog { @NonNull public String data; - enum Type {General, Statistics, Scheduling, Network, Account, Protocol} + enum Type {General, Statistics, Scheduling, Network, Account, Protocol, Classification} private static final ExecutorService executor = Helper.getBackgroundExecutor(1, "log"); diff --git a/app/src/main/java/eu/faircode/email/MessageClassifier.java b/app/src/main/java/eu/faircode/email/MessageClassifier.java index 09daa560da..87960b6054 100644 --- a/app/src/main/java/eu/faircode/email/MessageClassifier.java +++ b/app/src/main/java/eu/faircode/email/MessageClassifier.java @@ -90,14 +90,15 @@ public class MessageClassifier { String classified = classify(folder.account, folder.name, texts, target == null, context); long elapsed = new Date().getTime() - start; - EntityLog.log(context, "Classifier" + - " folder=" + folder.name + - " message=" + message.id + - "@" + new Date(message.received) + - ":" + message.subject + - " class=" + classified + - " re=" + message.auto_classified + - " elapsed=" + elapsed); + EntityLog.log(context, EntityLog.Type.Classification, + "Classifier" + + " folder=" + folder.name + + " message=" + message.id + + "@" + new Date(message.received) + + ":" + message.subject + + " class=" + classified + + " re=" + message.auto_classified + + " elapsed=" + elapsed); // Auto classify message if (classified != null && @@ -182,7 +183,8 @@ public class MessageClassifier { for (String clazz : new ArrayList<>(classMessages.get(account).keySet())) { EntityFolder folder = db.folder().getFolderByName(account, clazz); if (folder == null) { - EntityLog.log(context, "Classifier deleting folder class=" + account + ":" + clazz); + EntityLog.log(context, EntityLog.Type.Classification, + "Classifier deleting folder class=" + account + ":" + clazz); classMessages.get(account).remove(clazz); for (String word : wordClassFrequency.get(account).keySet()) wordClassFrequency.get(account).get(word).remove(clazz); @@ -250,10 +252,11 @@ public class MessageClassifier { double chance = stat.totalFrequency / maxMessages / words; Chance c = new Chance(clazz, chance); chances.add(c); - EntityLog.log(context, "Classifier " + c + - " frequency=" + (Math.round(stat.totalFrequency * 100.0) / 100.0) + "/" + maxMessages + " msgs" + - " matched=" + stat.matchedWords + "/" + words + " words" + - " text=" + TextUtils.join(", ", stat.words)); + EntityLog.log(context, EntityLog.Type.Classification, + "Classifier " + c + + " frequency=" + (Math.round(stat.totalFrequency * 100.0) / 100.0) + "/" + maxMessages + " msgs" + + " matched=" + stat.matchedWords + "/" + words + " words" + + " text=" + TextUtils.join(", ", stat.words)); } if (BuildConfig.DEBUG)