From 94250953c0e5b2a96d0a820d1f710c4bd31e80b2 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 29 Apr 2022 09:17:44 +0200 Subject: [PATCH] Classifier special case: pick first best --- .../eu/faircode/email/MessageClassifier.java | 19 ++++++++++++++++--- 1 file changed, 16 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 0554dc42c9..46c7805244 100644 --- a/app/src/main/java/eu/faircode/email/MessageClassifier.java +++ b/app/src/main/java/eu/faircode/email/MessageClassifier.java @@ -263,9 +263,6 @@ public class MessageClassifier { if (BuildConfig.DEBUG) Log.i("Classifier words=" + state.words.size() + " " + TextUtils.join(", ", state.words)); - if (chances.size() <= 1) - return null; - // Sort classes by chance Collections.sort(chances, new Comparator() { @Override @@ -278,6 +275,22 @@ public class MessageClassifier { double class_min_chance = prefs.getInt("class_min_probability", 15) / 100.0; double class_min_difference = prefs.getInt("class_min_difference", 50) / 100.0; + // Special case: pick first best target class + if (class_min_difference == 0) { + for (Chance chance : chances) + if (chance.chance > class_min_chance) { + EntityFolder target = db.folder().getFolderByName(message.account, chance.clazz); + if (target != null && target.auto_classify_target) { + Log.i("Classifier current=" + currentClass + " classified=" + chance.clazz); + return chance.clazz; + } + } + return null; + } + + if (chances.size() <= 1) + return null; + // Select best class String classification = null; double c0 = chances.get(0).chance;