aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java')
-rw-r--r--java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java32
1 files changed, 22 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
index b1966bffc..37879cf68 100644
--- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
@@ -122,12 +122,6 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
return mBinaryDictionary.isValidDictionary();
}
- // TODO: Remove and always enable beginning of sentence prediction. Currently, this is enabled
- // only for ContextualDictionary.
- protected boolean enableBeginningOfSentencePrediction() {
- return false;
- }
-
/**
* Creates a new expandable binary dictionary.
*
@@ -311,6 +305,27 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
}
/**
+ * Dynamically remove the unigram entry from the dictionary.
+ */
+ public void removeUnigramEntryDynamically(final String word) {
+ reloadDictionaryIfRequired();
+ asyncExecuteTaskWithWriteLock(new Runnable() {
+ @Override
+ public void run() {
+ if (mBinaryDictionary == null) {
+ return;
+ }
+ runGCIfRequiredLocked(true /* mindsBlockByGC */);
+ if (!mBinaryDictionary.removeUnigramEntry(word)) {
+ if (DEBUG) {
+ Log.i(TAG, "Cannot remove unigram entry: " + word);
+ }
+ }
+ }
+ });
+ }
+
+ /**
* Adds n-gram information of a word to the dictionary. May overwrite an existing entry.
*/
public void addNgramEntry(final PrevWordsInfo prevWordsInfo, final String word,
@@ -341,6 +356,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
/**
* Dynamically remove the n-gram entry in the dictionary.
*/
+ @UsedForTesting
public void removeNgramDynamically(final PrevWordsInfo prevWordsInfo, final String word) {
reloadDictionaryIfRequired();
asyncExecuteTaskWithWriteLock(new Runnable() {
@@ -404,10 +420,6 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
if (mBinaryDictionary == null) {
return null;
}
- if (composer.size() == 0 && prevWordsInfo.mIsBeginningOfSentence
- && !enableBeginningOfSentencePrediction()) {
- return null;
- }
final ArrayList<SuggestedWordInfo> suggestions =
mBinaryDictionary.getSuggestions(composer, prevWordsInfo, proximityInfo,
blockOffensiveWords, additionalFeaturesOptions, sessionId,