Added classifier version

pull/209/head
M66B 2 years ago
parent 67fa8ca8e2
commit 26d7fe4269

@ -48,6 +48,7 @@ import javax.mail.Address;
import javax.mail.internet.InternetAddress;
public class MessageClassifier {
private static int version = 3;
private static boolean loaded = false;
private static boolean dirty = false;
private static final Map<Long, List<String>> accountMsgIds = new HashMap<>();
@ -425,7 +426,8 @@ public class MessageClassifier {
try (JsonWriter writer = new JsonWriter(new BufferedWriter(new FileWriter(file)))) {
writer.beginObject();
writer.name("version").value(2);
Log.i("Classifier write version=" + version);
writer.name("version").value(version);
writer.name("messages");
writer.beginArray();
@ -517,13 +519,15 @@ public class MessageClassifier {
private static synchronized void _load(File file) throws IOException {
Log.i("Classifier read " + file);
long start = new Date().getTime();
version = 0;
if (file.exists())
try (JsonReader reader = new JsonReader(new BufferedReader(new FileReader(file)))) {
reader.beginObject();
while (reader.hasNext())
switch (reader.nextName()) {
case "version":
reader.nextInt();
version = reader.nextInt();
Log.i("Classifier read version=" + version);
break;
case "messages":
@ -684,7 +688,7 @@ public class MessageClassifier {
Log.i("Classifier dropping account=" + account +
" word=" + word + " class=" + clazz + " freq=" + freq.count + " avg=" + avg);
wordClassFrequency.get(account).get(word).remove(clazz);
} else if (false) {
} else if (version >= 3) {
for (String b : new ArrayList<>(freq.before.keySet()))
if (freq.before.get(b) < freq.count / 20)
freq.before.remove(b);

Loading…
Cancel
Save