From d9a8f2a82f6a0157c48ff1d0f8b2e05d40618426 Mon Sep 17 00:00:00 2001 From: Keisuke Kuroyanagi Date: Mon, 28 Jul 2014 19:18:04 +0900 Subject: [PATCH] Allow adding DICTIONARY_MAX_WORD_LENGTH-length words. Bug: 12725817 Change-Id: Ib9b30473ba94242a7b97ccd3b850068f596a5d17 --- .../android/inputmethod/latin/ContactsBinaryDictionary.java | 2 +- .../com/android/inputmethod/latin/UserBinaryDictionary.java | 4 ++-- .../latin/personalization/UserHistoryDictionary.java | 4 ++-- .../android/inputmethod/latin/utils/DictionaryInfoUtils.java | 3 +-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java index ad14c06ef..162a209e3 100644 --- a/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java @@ -231,7 +231,7 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary { // Don't add single letter words, possibly confuses // capitalization of i. final int wordLen = StringUtils.codePointCount(word); - if (wordLen < MAX_WORD_LENGTH && wordLen > 1) { + if (wordLen <= MAX_WORD_LENGTH && wordLen > 1) { if (DEBUG) { Log.d(TAG, "addName " + name + ", " + word + ", " + prevWordsInfo); } diff --git a/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java b/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java index debaad13e..21014b378 100644 --- a/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java @@ -253,12 +253,12 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary { final int frequency = cursor.getInt(indexFrequency); final int adjustedFrequency = scaleFrequencyFromDefaultToLatinIme(frequency); // Safeguard against adding really long words. - if (word.length() < MAX_WORD_LENGTH) { + if (word.length() <= MAX_WORD_LENGTH) { runGCIfRequiredLocked(true /* mindsBlockByGC */); addUnigramLocked(word, adjustedFrequency, null /* shortcutTarget */, 0 /* shortcutFreq */, false /* isNotAWord */, false /* isBlacklisted */, BinaryDictionary.NOT_A_VALID_TIMESTAMP); - if (null != shortcut && shortcut.length() < MAX_WORD_LENGTH) { + if (null != shortcut && shortcut.length() <= MAX_WORD_LENGTH) { runGCIfRequiredLocked(true /* mindsBlockByGC */); addUnigramLocked(shortcut, adjustedFrequency, word, USER_DICT_SHORTCUT_FREQUENCY, true /* isNotAWord */, diff --git a/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java b/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java index 8e027e4f9..34d4d4ed7 100644 --- a/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java +++ b/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java @@ -62,8 +62,8 @@ public class UserHistoryDictionary extends DecayingExpandableBinaryDictionaryBas final PrevWordsInfo prevWordsInfo, final String word, final boolean isValid, final int timestamp, final DistracterFilter distracterFilter) { final CharSequence prevWord = prevWordsInfo.mPrevWordsInfo[0].mWord; - if (word.length() >= Constants.DICTIONARY_MAX_WORD_LENGTH || - (prevWord != null && prevWord.length() >= Constants.DICTIONARY_MAX_WORD_LENGTH)) { + if (word.length() > Constants.DICTIONARY_MAX_WORD_LENGTH || + (prevWord != null && prevWord.length() > Constants.DICTIONARY_MAX_WORD_LENGTH)) { return; } final int frequency = isValid ? diff --git a/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java b/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java index d76ea10c0..197908032 100644 --- a/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java @@ -386,8 +386,7 @@ public class DictionaryInfoUtils { final SpacingAndPunctuations spacingAndPunctuations) { if (TextUtils.isEmpty(text)) return false; final int length = text.length(); - // TODO: Make this test "length > Constants.DICTIONARY_MAX_WORD_LENGTH". - if (length >= Constants.DICTIONARY_MAX_WORD_LENGTH) { + if (length > Constants.DICTIONARY_MAX_WORD_LENGTH) { return false; } int i = 0;