Reduction, step 7
Change-Id: I177ef2f29c8b6000c5e3d021c016c5d216fe3fc6
This commit is contained in:
parent
a3ee019331
commit
a333ff19ef
2 changed files with 26 additions and 26 deletions
|
@ -2034,12 +2034,16 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CharSequence prevWord = EditingUtils.getThisWord(getCurrentInputConnection(),
|
final SuggestedWords.Builder builder;
|
||||||
mSettingsValues.mWordSeparators);
|
if (mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM) {
|
||||||
SuggestedWords.Builder builder = mSuggest.getBigramPredictionWordBuilder(prevWord,
|
final CharSequence prevWord = EditingUtils.getThisWord(getCurrentInputConnection(),
|
||||||
mCorrectionMode);
|
mSettingsValues.mWordSeparators);
|
||||||
|
builder = mSuggest.getBigramPredictionWordBuilder(prevWord);
|
||||||
|
} else {
|
||||||
|
builder = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (builder.size() > 0) {
|
if (null == builder || builder.size() > 0) {
|
||||||
// Explicitly supply an empty typed word (the no-second-arg version of
|
// Explicitly supply an empty typed word (the no-second-arg version of
|
||||||
// showSuggestions will retrieve the word near the cursor, we don't want that here)
|
// showSuggestions will retrieve the word near the cursor, we don't want that here)
|
||||||
showSuggestions(builder.build(), "");
|
showSuggestions(builder.build(), "");
|
||||||
|
|
|
@ -261,8 +261,7 @@ public class Suggest implements Dictionary.WordCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final WordComposer sEmptyWordComposer = new WordComposer();
|
private static final WordComposer sEmptyWordComposer = new WordComposer();
|
||||||
public SuggestedWords.Builder getBigramPredictionWordBuilder(CharSequence prevWordForBigram,
|
public SuggestedWords.Builder getBigramPredictionWordBuilder(CharSequence prevWordForBigram) {
|
||||||
final int correctionMode) {
|
|
||||||
LatinImeLogger.onStartSuggestion(prevWordForBigram);
|
LatinImeLogger.onStartSuggestion(prevWordForBigram);
|
||||||
mIsFirstCharCapitalized = false;
|
mIsFirstCharCapitalized = false;
|
||||||
mIsAllUpperCase = false;
|
mIsAllUpperCase = false;
|
||||||
|
@ -274,26 +273,23 @@ public class Suggest implements Dictionary.WordCallback {
|
||||||
LatinImeLogger.onAddSuggestedWord("", Suggest.DIC_USER_TYPED, Dictionary.UNIGRAM);
|
LatinImeLogger.onAddSuggestedWord("", Suggest.DIC_USER_TYPED, Dictionary.UNIGRAM);
|
||||||
mConsideredWord = "";
|
mConsideredWord = "";
|
||||||
|
|
||||||
// Note that if correctionMode != CORRECTION_FULL_BIGRAM, we'll always return the
|
Arrays.fill(mBigramScores, 0);
|
||||||
// same empty SuggestedWords.Builder, which has size() == 0
|
collectGarbage(mBigramSuggestions, PREF_MAX_BIGRAMS);
|
||||||
if (correctionMode == CORRECTION_FULL_BIGRAM) {
|
|
||||||
// At first character typed, search only the bigrams
|
|
||||||
Arrays.fill(mBigramScores, 0);
|
|
||||||
collectGarbage(mBigramSuggestions, PREF_MAX_BIGRAMS);
|
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(prevWordForBigram)) {
|
// Note that if prevWordForBigram is empty, we'll always return the same empty
|
||||||
CharSequence lowerPrevWord = prevWordForBigram.toString().toLowerCase();
|
// SuggestedWords.Builder
|
||||||
if (mMainDict != null && mMainDict.isValidWord(lowerPrevWord)) {
|
if (!TextUtils.isEmpty(prevWordForBigram)) {
|
||||||
prevWordForBigram = lowerPrevWord;
|
CharSequence lowerPrevWord = prevWordForBigram.toString().toLowerCase();
|
||||||
}
|
if (mMainDict != null && mMainDict.isValidWord(lowerPrevWord)) {
|
||||||
for (final Dictionary dictionary : mBigramDictionaries.values()) {
|
prevWordForBigram = lowerPrevWord;
|
||||||
dictionary.getBigrams(sEmptyWordComposer, prevWordForBigram, this);
|
}
|
||||||
}
|
for (final Dictionary dictionary : mBigramDictionaries.values()) {
|
||||||
// Nothing entered: return all bigrams for the previous word
|
dictionary.getBigrams(sEmptyWordComposer, prevWordForBigram, this);
|
||||||
int insertCount = Math.min(mBigramSuggestions.size(), mPrefMaxSuggestions);
|
}
|
||||||
for (int i = 0; i < insertCount; ++i) {
|
// Nothing entered: return all bigrams for the previous word
|
||||||
addBigramToSuggestions(mBigramSuggestions.get(i));
|
int insertCount = Math.min(mBigramSuggestions.size(), mPrefMaxSuggestions);
|
||||||
}
|
for (int i = 0; i < insertCount; ++i) {
|
||||||
|
addBigramToSuggestions(mBigramSuggestions.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue