am e642693a: am 5e6431ce: am c6862ee6: Merge "Allow adding DICTIONARY_MAX_WORD_LENGTH-length words." into lmp-dev
* commit 'e642693a59f919aa0d124358cc352d22510a39db': Allow adding DICTIONARY_MAX_WORD_LENGTH-length words.main
commit
f468fd7c11
|
@ -231,7 +231,7 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
// Don't add single letter words, possibly confuses
|
// Don't add single letter words, possibly confuses
|
||||||
// capitalization of i.
|
// capitalization of i.
|
||||||
final int wordLen = StringUtils.codePointCount(word);
|
final int wordLen = StringUtils.codePointCount(word);
|
||||||
if (wordLen < MAX_WORD_LENGTH && wordLen > 1) {
|
if (wordLen <= MAX_WORD_LENGTH && wordLen > 1) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "addName " + name + ", " + word + ", " + prevWordsInfo);
|
Log.d(TAG, "addName " + name + ", " + word + ", " + prevWordsInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,12 +253,12 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
final int frequency = cursor.getInt(indexFrequency);
|
final int frequency = cursor.getInt(indexFrequency);
|
||||||
final int adjustedFrequency = scaleFrequencyFromDefaultToLatinIme(frequency);
|
final int adjustedFrequency = scaleFrequencyFromDefaultToLatinIme(frequency);
|
||||||
// Safeguard against adding really long words.
|
// Safeguard against adding really long words.
|
||||||
if (word.length() < MAX_WORD_LENGTH) {
|
if (word.length() <= MAX_WORD_LENGTH) {
|
||||||
runGCIfRequiredLocked(true /* mindsBlockByGC */);
|
runGCIfRequiredLocked(true /* mindsBlockByGC */);
|
||||||
addUnigramLocked(word, adjustedFrequency, null /* shortcutTarget */,
|
addUnigramLocked(word, adjustedFrequency, null /* shortcutTarget */,
|
||||||
0 /* shortcutFreq */, false /* isNotAWord */,
|
0 /* shortcutFreq */, false /* isNotAWord */,
|
||||||
false /* isBlacklisted */, BinaryDictionary.NOT_A_VALID_TIMESTAMP);
|
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 */);
|
runGCIfRequiredLocked(true /* mindsBlockByGC */);
|
||||||
addUnigramLocked(shortcut, adjustedFrequency, word,
|
addUnigramLocked(shortcut, adjustedFrequency, word,
|
||||||
USER_DICT_SHORTCUT_FREQUENCY, true /* isNotAWord */,
|
USER_DICT_SHORTCUT_FREQUENCY, true /* isNotAWord */,
|
||||||
|
|
|
@ -62,8 +62,8 @@ public class UserHistoryDictionary extends DecayingExpandableBinaryDictionaryBas
|
||||||
final PrevWordsInfo prevWordsInfo, final String word, final boolean isValid,
|
final PrevWordsInfo prevWordsInfo, final String word, final boolean isValid,
|
||||||
final int timestamp, final DistracterFilter distracterFilter) {
|
final int timestamp, final DistracterFilter distracterFilter) {
|
||||||
final CharSequence prevWord = prevWordsInfo.mPrevWordsInfo[0].mWord;
|
final CharSequence prevWord = prevWordsInfo.mPrevWordsInfo[0].mWord;
|
||||||
if (word.length() >= Constants.DICTIONARY_MAX_WORD_LENGTH ||
|
if (word.length() > Constants.DICTIONARY_MAX_WORD_LENGTH ||
|
||||||
(prevWord != null && prevWord.length() >= Constants.DICTIONARY_MAX_WORD_LENGTH)) {
|
(prevWord != null && prevWord.length() > Constants.DICTIONARY_MAX_WORD_LENGTH)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int frequency = isValid ?
|
final int frequency = isValid ?
|
||||||
|
|
|
@ -386,8 +386,7 @@ public class DictionaryInfoUtils {
|
||||||
final SpacingAndPunctuations spacingAndPunctuations) {
|
final SpacingAndPunctuations spacingAndPunctuations) {
|
||||||
if (TextUtils.isEmpty(text)) return false;
|
if (TextUtils.isEmpty(text)) return false;
|
||||||
final int length = text.length();
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
Loading…
Reference in New Issue