Merge "Make Beginning-of-Sentence prediction require two exposures."
This commit is contained in:
commit
520765491c
3 changed files with 21 additions and 5 deletions
|
@ -75,7 +75,13 @@ public class UserHistoryDictionary extends DecayingExpandableBinaryDictionaryBas
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (null != prevWord) {
|
if (null != prevWord) {
|
||||||
|
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);
|
userHistoryDictionary.addNgramEntry(prevWordsInfo, word, frequency, timestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,10 @@ void BigramDictionary::getPredictions(const PrevWordsInfo *const prevWordsInfo,
|
||||||
if (bigramsIt.getBigramPos() == NOT_A_DICT_POS) {
|
if (bigramsIt.getBigramPos() == NOT_A_DICT_POS) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (prevWordsInfo->isNthPrevWordBeginningOfSentence(1 /* n */)
|
||||||
|
&& bigramsIt.getProbability() == NOT_A_PROBABILITY) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const int codePointCount = mDictionaryStructurePolicy->
|
const int codePointCount = mDictionaryStructurePolicy->
|
||||||
getCodePointsAndProbabilityAndReturnCodePointCount(bigramsIt.getBigramPos(),
|
getCodePointsAndProbabilityAndReturnCodePointCount(bigramsIt.getBigramPos(),
|
||||||
MAX_WORD_LENGTH, bigramCodePoints, &unigramProbability);
|
MAX_WORD_LENGTH, bigramCodePoints, &unigramProbability);
|
||||||
|
|
|
@ -517,15 +517,21 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
|
suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNoPredictionsAfterPeriod() {
|
public void testPredictionsAfterPeriod() {
|
||||||
mLatinIME.clearPersonalizedDictionariesForTest();
|
mLatinIME.clearPersonalizedDictionariesForTest();
|
||||||
final String WORD_TO_TYPE = "Barack. ";
|
final String WORD_TO_TYPE = "Barack. ";
|
||||||
type(WORD_TO_TYPE);
|
type(WORD_TO_TYPE);
|
||||||
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
|
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
|
||||||
runMessages();
|
runMessages();
|
||||||
// Test the first prediction is not displayed
|
SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest();
|
||||||
final SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest();
|
assertEquals("No prediction after period after inputting once.", 0, suggestedWords.size());
|
||||||
assertEquals("no prediction after period", 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() {
|
public void testPredictionsAfterRecorrection() {
|
||||||
|
|
Loading…
Reference in a new issue