Added classifier logging

This commit is contained in:
M66B 2021-01-06 18:23:58 +01:00
parent cc78faa56c
commit 63beb8f87d
1 changed files with 8 additions and 2 deletions

View File

@ -203,6 +203,8 @@ public class MessageClassifier {
stat.matchedWords++; stat.matchedWords++;
stat.totalFrequency += frequency; stat.totalFrequency += frequency;
if (BuildConfig.DEBUG)
stat.words.add(word);
if (stat.matchedWords > maxMatchedWords) if (stat.matchedWords > maxMatchedWords)
maxMatchedWords = stat.matchedWords; maxMatchedWords = stat.matchedWords;
@ -245,12 +247,15 @@ public class MessageClassifier {
} }
Stat stat = classStats.get(clazz); Stat stat = classStats.get(clazz);
boolean consider = (stat.matchedWords >= MIN_MATCHED_WORDS);
double chance = (double) stat.totalFrequency / messages / maxMatchedWords; double chance = (double) stat.totalFrequency / messages / maxMatchedWords;
Chance c = new Chance(clazz, chance); Chance c = new Chance(clazz, chance);
EntityLog.log(context, "Classifier " + c + EntityLog.log(context, "Classifier " + c +
" frequency=" + stat.totalFrequency + "/" + messages + " frequency=" + stat.totalFrequency + "/" + messages +
" matched=" + stat.matchedWords + "/" + maxMatchedWords); " matched=" + stat.matchedWords + "/" + maxMatchedWords +
if (stat.matchedWords >= MIN_MATCHED_WORDS) " consider=" + consider +
" words=" + TextUtils.join(", ", stat.words));
if (consider)
chances.add(c); chances.add(c);
} }
@ -387,6 +392,7 @@ public class MessageClassifier {
private static class Stat { private static class Stat {
int matchedWords = 0; int matchedWords = 0;
int totalFrequency = 0; int totalFrequency = 0;
List<String> words = new ArrayList<>();
} }
private static class Chance { private static class Chance {