Small classifier fix / simplification

This commit is contained in:
M66B 2022-04-28 13:59:46 +02:00
parent d87a925aa2
commit f66e837883
2 changed files with 8 additions and 10 deletions

View File

@ -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();

View File

@ -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 +