From 12d80ebead6a1d7f704a5a3af3b6fe3313ceab05 Mon Sep 17 00:00:00 2001 From: Dan Zivkovic Date: Tue, 10 Feb 2015 14:54:38 -0800 Subject: Remove shortcut support from LatinIME. Note this change does not affect the native decoder interface. Change-Id: I73b7dc008a5acaf75a31a36a2d332b5afabd82d0 --- .../latin/ExpandableBinaryDictionary.java | 53 ++++++---------------- 1 file changed, 15 insertions(+), 38 deletions(-) (limited to 'java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java') diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java index 413c5b8a1..8c780027b 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java @@ -297,21 +297,18 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { * Adds unigram information of a word to the dictionary. May overwrite an existing entry. */ public void addUnigramEntry(final String word, final int frequency, - final String shortcutTarget, final int shortcutFreq, final boolean isNotAWord, - final boolean isPossiblyOffensive, final int timestamp) { + final boolean isNotAWord, final boolean isPossiblyOffensive, final int timestamp) { updateDictionaryWithWriteLock(new Runnable() { @Override public void run() { - addUnigramLocked(word, frequency, shortcutTarget, shortcutFreq, - isNotAWord, isPossiblyOffensive, timestamp); + addUnigramLocked(word, frequency, isNotAWord, isPossiblyOffensive, timestamp); } }); } protected void addUnigramLocked(final String word, final int frequency, - final String shortcutTarget, final int shortcutFreq, final boolean isNotAWord, - final boolean isPossiblyOffensive, final int timestamp) { - if (!mBinaryDictionary.addUnigramEntry(word, frequency, shortcutTarget, shortcutFreq, + final boolean isNotAWord, final boolean isPossiblyOffensive, final int timestamp) { + if (!mBinaryDictionary.addUnigramEntry(word, frequency, false /* isBeginningOfSentence */, isNotAWord, isPossiblyOffensive, timestamp)) { Log.e(TAG, "Cannot add unigram entry. word: " + word); } @@ -367,31 +364,6 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { } } - /** - * Dynamically remove the n-gram entry in the dictionary. - */ - @UsedForTesting - public void removeNgramDynamically(@Nonnull final NgramContext ngramContext, - final String word) { - reloadDictionaryIfRequired(); - asyncExecuteTaskWithWriteLock(new Runnable() { - @Override - public void run() { - final BinaryDictionary binaryDictionary = getBinaryDictionary(); - if (binaryDictionary == null) { - return; - } - runGCIfRequiredLocked(true /* mindsBlockByGC */); - if (!binaryDictionary.removeNgramEntry(ngramContext, word)) { - if (DEBUG) { - Log.i(TAG, "Cannot remove n-gram entry."); - Log.i(TAG, " NgramContext: " + ngramContext + ", word: " + word); - } - } - } - }); - } - /** * Update dictionary for the word with the ngramContext. */ @@ -408,20 +380,29 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { isValidWord, count, timestamp)) { if (DEBUG) { Log.e(TAG, "Cannot update counter. word: " + word - + " context: "+ ngramContext.toString()); + + " context: " + ngramContext.toString()); } } } }); } + /** + * Used by Sketch. + * {@see https://cs.corp.google.com/#android/vendor/unbundled_google/packages/LatinIMEGoogle/tools/sketch/ime-simulator/src/com/android/inputmethod/sketch/imesimulator/ImeSimulator.java&q=updateEntriesForInputEventsCallback&l=286} + */ + @UsedForTesting public interface UpdateEntriesForInputEventsCallback { public void onFinished(); } /** * Dynamically update entries according to input events. + * + * Used by Sketch. + * {@see https://cs.corp.google.com/#android/vendor/unbundled_google/packages/LatinIMEGoogle/tools/sketch/ime-simulator/src/com/android/inputmethod/sketch/imesimulator/ImeSimulator.java&q=updateEntriesForInputEventsCallback&l=286} */ + @UsedForTesting public void updateEntriesForInputEvents( @Nonnull final ArrayList inputEvents, final UpdateEntriesForInputEventsCallback callback) { @@ -533,11 +514,6 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { } - protected boolean isValidNgramLocked(final NgramContext ngramContext, final String word) { - if (mBinaryDictionary == null) return false; - return mBinaryDictionary.isValidNgram(ngramContext, word); - } - /** * Loads the current binary dictionary from internal storage. Assumes the dictionary file * exists. @@ -551,6 +527,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { Thread.sleep(15000); Log.w(TAG, "End stress in loading"); } catch (InterruptedException e) { + Log.w("Interrupted while loading: " + mDictName, e); } } final BinaryDictionary oldBinaryDictionary = mBinaryDictionary; -- cgit v1.2.3-83-g751a