From 271e731eb4265a188e1bc7cbbc3d14ad97162409 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 1 Nov 2012 14:22:37 +0900 Subject: [PATCH] Add a missing report, and fix a wrong report Deleted words would be reported, but added words wouldn't Also, shortcuts would be reported as bigrams Change-Id: I017653f2afa65cf16924017a0be2ee2cbd6ca10d --- .../inputmethod/latin/dicttool/Diff.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java index dcbfb39b7..94db84497 100644 --- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java +++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java @@ -144,9 +144,17 @@ public class Diff extends Dicttool.Command { hasDifferences = true; } hasDifferences |= hasAttributesDifferencesAndPrintThemIfAny(word0.mWord, - word0.mBigrams, word1.getBigrams()); + "Bigram", word0.mBigrams, word1.getBigrams()); hasDifferences |= hasAttributesDifferencesAndPrintThemIfAny(word0.mWord, - word0.mShortcutTargets, word1.getShortcutTargets()); + "Shortcut", word0.mShortcutTargets, word1.getShortcutTargets()); + } + } + for (final Word word1 : dict1) { + final CharGroup word0 = FusionDictionary.findWordInTree(dict0.mRoot, word1.mWord); + if (null == word0) { + // This word is not in dict0 + System.out.println("Added: " + word1.mWord + " " + word1.mFrequency); + hasDifferences = true; } } if (!hasDifferences) { @@ -155,11 +163,12 @@ public class Diff extends Dicttool.Command { } private static boolean hasAttributesDifferencesAndPrintThemIfAny(final String word, - final ArrayList list0, final ArrayList list1) { + final String type, final ArrayList list0, + final ArrayList list1) { if (null == list1) { if (null == list0) return false; for (final WeightedString attribute0 : list0) { - System.out.println("Bigram removed: " + word + " " + attribute0.mWord + " " + System.out.println(type + " removed: " + word + " " + attribute0.mWord + " " + attribute0.mFrequency); } return true; @@ -174,14 +183,14 @@ public class Diff extends Dicttool.Command { // Search for a word with the same string but a different frequency for (final WeightedString attribute1 : list1) { if (attribute0.mWord.equals(attribute1.mWord)) { - System.out.println("Bigram freq changed: " + word + " " + System.out.println(type + " freq changed: " + word + " " + attribute0.mWord + " " + attribute0.mFrequency + " -> " + attribute1.mFrequency); list1.remove(attribute1); break; } // We come here if we haven't found any matching string. - System.out.println("Bigram removed: " + word + " " + attribute0.mWord); + System.out.println(type + " removed: " + word + " " + attribute0.mWord); } } else { list1.remove(attribute0); @@ -192,7 +201,7 @@ public class Diff extends Dicttool.Command { // are not included in list0. for (final WeightedString attribute1 : list1) { hasDifferences = true; - System.out.println("Bigram added: " + word + " " + attribute1.mWord + " " + System.out.println(type + " added: " + word + " " + attribute1.mWord + " " + attribute1.mFrequency); } return hasDifferences;