Make Beginning-of-Sentence prediction require two exposures.
Bug: 15868192 Change-Id: I4b577ad11c992d872d6f902fd50527d9ca5cc1ba
parent
3c07fcbc54
commit
0aef59746c
|
@ -75,7 +75,13 @@ public class UserHistoryDictionary extends DecayingExpandableBinaryDictionaryBas
|
|||
return;
|
||||
}
|
||||
if (null != prevWord) {
|
||||
userHistoryDictionary.addNgramEntry(prevWordsInfo, word, frequency, timestamp);
|
||||
if (prevWordsInfo.mIsBeginningOfSentence) {
|
||||
// Beginning-of-Sentence n-gram entry is treated as a n-gram entry of invalid word.
|
||||
userHistoryDictionary.addNgramEntry(prevWordsInfo, word,
|
||||
FREQUENCY_FOR_WORDS_NOT_IN_DICTS, timestamp);
|
||||
} else {
|
||||
userHistoryDictionary.addNgramEntry(prevWordsInfo, word, frequency, timestamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,10 @@ void BigramDictionary::getPredictions(const PrevWordsInfo *const prevWordsInfo,
|
|||
if (bigramsIt.getBigramPos() == NOT_A_DICT_POS) {
|
||||
continue;
|
||||
}
|
||||
if (prevWordsInfo->isNthPrevWordBeginningOfSentence(1 /* n */)
|
||||
&& bigramsIt.getProbability() == NOT_A_PROBABILITY) {
|
||||
continue;
|
||||
}
|
||||
const int codePointCount = mDictionaryStructurePolicy->
|
||||
getCodePointsAndProbabilityAndReturnCodePointCount(bigramsIt.getBigramPos(),
|
||||
MAX_WORD_LENGTH, bigramCodePoints, &unigramProbability);
|
||||
|
|
|
@ -517,15 +517,21 @@ public class InputLogicTests extends InputTestsBase {
|
|||
suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
|
||||
}
|
||||
|
||||
public void testNoPredictionsAfterPeriod() {
|
||||
public void testPredictionsAfterPeriod() {
|
||||
mLatinIME.clearPersonalizedDictionariesForTest();
|
||||
final String WORD_TO_TYPE = "Barack. ";
|
||||
type(WORD_TO_TYPE);
|
||||
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
|
||||
runMessages();
|
||||
// Test the first prediction is not displayed
|
||||
final SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest();
|
||||
assertEquals("no prediction after period", 0, suggestedWords.size());
|
||||
SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest();
|
||||
assertEquals("No prediction after period after inputting once.", 0, suggestedWords.size());
|
||||
|
||||
type(WORD_TO_TYPE);
|
||||
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
|
||||
runMessages();
|
||||
suggestedWords = mLatinIME.getSuggestedWordsForTest();
|
||||
assertEquals("Beginning-of-Sentence prediction after inputting 2 times.", "Barack",
|
||||
suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
|
||||
}
|
||||
|
||||
public void testPredictionsAfterRecorrection() {
|
||||
|
|
Loading…
Reference in New Issue