Added classifier logging

pull/191/head
M66B 4 years ago
parent cc78faa56c
commit 63beb8f87d

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

Loading…
Cancel
Save