From 6145b7352398989be3f2bc9eb974013b0039a3a4 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Mon, 16 Jan 2012 17:45:53 +0900 Subject: [PATCH] Add shortcut only to xml output. Change-Id: I23b53826ce30b0ac81962d2f916514cb60bea6ff --- .../src/com/android/inputmethod/latin/FusionDictionary.java | 3 ++- tools/makedict/src/com/android/inputmethod/latin/Word.java | 4 +++- .../com/android/inputmethod/latin/XmlDictInputOutput.java | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/makedict/src/com/android/inputmethod/latin/FusionDictionary.java b/tools/makedict/src/com/android/inputmethod/latin/FusionDictionary.java index 3ab206d80..8b94485e4 100644 --- a/tools/makedict/src/com/android/inputmethod/latin/FusionDictionary.java +++ b/tools/makedict/src/com/android/inputmethod/latin/FusionDictionary.java @@ -619,7 +619,8 @@ public class FusionDictionary implements Iterable { } if (currentGroup.mFrequency >= 0) return new Word(mCurrentString.toString(), currentGroup.mFrequency, - currentGroup.mShortcutTargets, currentGroup.mBigrams); + currentGroup.mShortcutTargets, currentGroup.mBigrams, + currentGroup.mIsShortcutOnly); } else { mPositions.removeLast(); currentPos = mPositions.getLast(); diff --git a/tools/makedict/src/com/android/inputmethod/latin/Word.java b/tools/makedict/src/com/android/inputmethod/latin/Word.java index 561b21bb3..cf6116f91 100644 --- a/tools/makedict/src/com/android/inputmethod/latin/Word.java +++ b/tools/makedict/src/com/android/inputmethod/latin/Word.java @@ -28,16 +28,18 @@ import java.util.ArrayList; public class Word implements Comparable { final String mWord; final int mFrequency; + final boolean mIsShortcutOnly; final ArrayList mShortcutTargets; final ArrayList mBigrams; public Word(final String word, final int frequency, final ArrayList shortcutTargets, - final ArrayList bigrams) { + final ArrayList bigrams, final boolean isShortcutOnly) { mWord = word; mFrequency = frequency; mShortcutTargets = shortcutTargets; mBigrams = bigrams; + mIsShortcutOnly = isShortcutOnly; } /** diff --git a/tools/makedict/src/com/android/inputmethod/latin/XmlDictInputOutput.java b/tools/makedict/src/com/android/inputmethod/latin/XmlDictInputOutput.java index d6c03ed70..a13a3b88f 100644 --- a/tools/makedict/src/com/android/inputmethod/latin/XmlDictInputOutput.java +++ b/tools/makedict/src/com/android/inputmethod/latin/XmlDictInputOutput.java @@ -45,6 +45,7 @@ public class XmlDictInputOutput { private static final String SHORTCUT_TAG = "shortcut"; private static final String FREQUENCY_ATTR = "f"; private static final String WORD_ATTR = "word"; + private static final String SHORTCUT_ONLY_ATTR = "shortcutOnly"; /** * SAX handler for a unigram XML file. @@ -264,9 +265,11 @@ public class XmlDictInputOutput { } // TODO: use an XMLSerializer if this gets big destination.write("\n"); + destination.write("\n"); for (Word word : set) { destination.write(" <" + WORD_TAG + " " + WORD_ATTR + "=\"" + word.mWord + "\" " - + FREQUENCY_ATTR + "=\"" + word.mFrequency + "\">"); + + FREQUENCY_ATTR + "=\"" + word.mFrequency + "\" " + SHORTCUT_ONLY_ATTR + + "=\"" + word.mIsShortcutOnly + "\">"); if (null != word.mShortcutTargets) { destination.write("\n"); for (WeightedString target : word.mShortcutTargets) {