From f66e8378834777ec2c444f118937b6b4d359cf94 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 28 Apr 2022 13:59:46 +0200 Subject: [PATCH] Small classifier fix / simplification --- app/src/main/java/eu/faircode/email/Core.java | 10 +++++----- .../main/java/eu/faircode/email/MessageClassifier.java | 8 +++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 87e31904a4..f7bbee0ae6 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -1385,7 +1385,7 @@ class Core { // De-classify if (!copy) for (EntityMessage message : messages) - MessageClassifier.classify(message, folder, target, context); + MessageClassifier.classify(message, folder, false, context); IMAPFolder itarget = (IMAPFolder) istore.getFolder(target.name); @@ -1997,7 +1997,7 @@ class Core { plain_only, message.preview, parts.getWarnings(message.warning)); - MessageClassifier.classify(message, folder, null, context); + MessageClassifier.classify(message, folder, true, context); if (body != null) EntityLog.log(context, "Operation body size=" + body.length()); @@ -4261,7 +4261,7 @@ class Core { parts.isPlainOnly(download_plain), message.preview, parts.getWarnings(message.warning)); - MessageClassifier.classify(message, folder, null, context); + MessageClassifier.classify(message, folder, true, context); if (stats != null && body != null) stats.content += body.length(); @@ -4428,7 +4428,7 @@ class Core { if (process) { EntityContact.received(context, account, folder, message); - MessageClassifier.classify(message, folder, null, context); + MessageClassifier.classify(message, folder, true, context); } else Log.d(folder.name + " unchanged uid=" + uid); @@ -4746,7 +4746,7 @@ class Core { parts.isPlainOnly(), message.preview, parts.getWarnings(message.warning)); - MessageClassifier.classify(message, folder, null, context); + MessageClassifier.classify(message, folder, true, context); if (stats != null && body != null) stats.content += body.length(); diff --git a/app/src/main/java/eu/faircode/email/MessageClassifier.java b/app/src/main/java/eu/faircode/email/MessageClassifier.java index f3a2f37523..941d7ede6e 100644 --- a/app/src/main/java/eu/faircode/email/MessageClassifier.java +++ b/app/src/main/java/eu/faircode/email/MessageClassifier.java @@ -56,7 +56,7 @@ public class MessageClassifier { private static final int MAX_WORDS = 1000; - static synchronized void classify(EntityMessage message, EntityFolder folder, EntityFolder target, Context context) { + static synchronized void classify(EntityMessage message, EntityFolder folder, boolean added, Context context) { try { if (!isEnabled(context)) return; @@ -64,9 +64,6 @@ public class MessageClassifier { if (!folder.auto_classify_source) return; - if (target != null && !target.auto_classify_source) - return; - long start = new Date().getTime(); // Build text to classify @@ -86,12 +83,13 @@ public class MessageClassifier { wordClassFrequency.put(folder.account, new HashMap<>()); // Classify texts - String classified = classify(message, folder.name, texts, target == null, context); + String classified = classify(message, folder.name, texts, added, context); long elapsed = new Date().getTime() - start; EntityLog.log(context, EntityLog.Type.Classification, message, "Classifier" + " folder=" + folder.name + + " added=" + added + " message=" + message.id + "@" + new Date(message.received) + ":" + message.subject +