am 552470c8: Merge "Make sure to suppress BoS prediction until input twice."
* commit '552470c882b96ce69f060f2f54470e4b19da9bd8': Make sure to suppress BoS prediction until input twice.main
commit
a3aa121c80
|
@ -378,7 +378,10 @@ bool Ver4PatriciaTriePolicy::updateCounter(const PrevWordsInfo *const prevWordsI
|
||||||
AKLOGE("Cannot update unigarm entry in updateCounter().");
|
AKLOGE("Cannot update unigarm entry in updateCounter().");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const NgramProperty ngramProperty(wordCodePoints.toVector(), probability, historicalInfo);
|
const int probabilityForNgram = prevWordsInfo->isNthPrevWordBeginningOfSentence(1 /* n */)
|
||||||
|
? NOT_A_PROBABILITY : probability;
|
||||||
|
const NgramProperty ngramProperty(wordCodePoints.toVector(), probabilityForNgram,
|
||||||
|
historicalInfo);
|
||||||
for (size_t i = 1; i <= prevWordsInfo->getPrevWordCount(); ++i) {
|
for (size_t i = 1; i <= prevWordsInfo->getPrevWordCount(); ++i) {
|
||||||
const PrevWordsInfo trimmedPrevWordsInfo(prevWordsInfo->getTrimmedPrevWordsInfo(i));
|
const PrevWordsInfo trimmedPrevWordsInfo(prevWordsInfo->getTrimmedPrevWordsInfo(i));
|
||||||
if (!addNgramEntry(&trimmedPrevWordsInfo, &ngramProperty)) {
|
if (!addNgramEntry(&trimmedPrevWordsInfo, &ngramProperty)) {
|
||||||
|
|
|
@ -611,20 +611,23 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase {
|
||||||
mCurrentTime);
|
mCurrentTime);
|
||||||
final NgramContext beginningOfSentenceContext = NgramContext.BEGINNING_OF_SENTENCE;
|
final NgramContext beginningOfSentenceContext = NgramContext.BEGINNING_OF_SENTENCE;
|
||||||
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "aaa", true /* isValidWord */);
|
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "aaa", true /* isValidWord */);
|
||||||
|
assertFalse(binaryDictionary.isValidNgram(beginningOfSentenceContext, "aaa"));
|
||||||
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "aaa", true /* isValidWord */);
|
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "aaa", true /* isValidWord */);
|
||||||
assertTrue(binaryDictionary.isValidNgram(beginningOfSentenceContext, "aaa"));
|
assertTrue(binaryDictionary.isValidNgram(beginningOfSentenceContext, "aaa"));
|
||||||
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "aaa", true /* isValidWord */);
|
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "aaa", true /* isValidWord */);
|
||||||
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "bbb", true /* isValidWord */);
|
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "bbb", true /* isValidWord */);
|
||||||
|
assertFalse(binaryDictionary.isValidNgram(beginningOfSentenceContext, "bbb"));
|
||||||
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "bbb", true /* isValidWord */);
|
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "bbb", true /* isValidWord */);
|
||||||
assertTrue(binaryDictionary.isValidNgram(beginningOfSentenceContext, "aaa"));
|
assertTrue(binaryDictionary.isValidNgram(beginningOfSentenceContext, "aaa"));
|
||||||
assertTrue(binaryDictionary.isValidNgram(beginningOfSentenceContext, "bbb"));
|
assertTrue(binaryDictionary.isValidNgram(beginningOfSentenceContext, "bbb"));
|
||||||
forcePassingLongTime(binaryDictionary);
|
forcePassingLongTime(binaryDictionary);
|
||||||
assertFalse(binaryDictionary.isValidNgram(beginningOfSentenceContext, "aaa"));
|
assertFalse(binaryDictionary.isValidNgram(beginningOfSentenceContext, "aaa"));
|
||||||
assertFalse(binaryDictionary.isValidNgram(beginningOfSentenceContext, "bbb"));
|
assertFalse(binaryDictionary.isValidNgram(beginningOfSentenceContext, "bbb"));
|
||||||
|
|
||||||
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "aaa", true /* isValidWord */);
|
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "aaa", true /* isValidWord */);
|
||||||
|
assertFalse(binaryDictionary.isValidNgram(beginningOfSentenceContext, "aaa"));
|
||||||
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "aaa", true /* isValidWord */);
|
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "aaa", true /* isValidWord */);
|
||||||
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "bbb", true /* isValidWord */);
|
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "bbb", true /* isValidWord */);
|
||||||
|
assertFalse(binaryDictionary.isValidNgram(beginningOfSentenceContext, "bbb"));
|
||||||
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "bbb", true /* isValidWord */);
|
onInputWordWithBeginningOfSentenceContext(binaryDictionary, "bbb", true /* isValidWord */);
|
||||||
assertTrue(binaryDictionary.isValidNgram(beginningOfSentenceContext, "aaa"));
|
assertTrue(binaryDictionary.isValidNgram(beginningOfSentenceContext, "aaa"));
|
||||||
assertTrue(binaryDictionary.isValidNgram(beginningOfSentenceContext, "bbb"));
|
assertTrue(binaryDictionary.isValidNgram(beginningOfSentenceContext, "bbb"));
|
||||||
|
|
Loading…
Reference in New Issue