diff options
author | 2014-10-21 17:12:32 +0900 | |
---|---|---|
committer | 2014-10-21 17:12:32 +0900 | |
commit | 88bb28c132d87f15a52e9a0b8a45950f39eb19ad (patch) | |
tree | ef09b985cc1c04ce962ab2b15927f2c1dfc3a2b8 /native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp | |
parent | f87bb77a9183d126847d5925c2b03bec45fabd6d (diff) | |
download | latinime-88bb28c132d87f15a52e9a0b8a45950f39eb19ad.tar.gz latinime-88bb28c132d87f15a52e9a0b8a45950f39eb19ad.tar.xz latinime-88bb28c132d87f15a52e9a0b8a45950f39eb19ad.zip |
Make NgramProperty have NgramContext.
Bug: 14425059
Change-Id: I210acb816b122857dbbe1ee4dd6a35c5335bf2bf
Diffstat (limited to 'native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp')
-rw-r--r-- | native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp index f8dadb488..1020f6865 100644 --- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp +++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp @@ -409,9 +409,10 @@ static bool latinime_BinaryDictionary_addNgramEntry(JNIEnv *env, jclass clazz, j int wordCodePoints[wordLength]; env->GetIntArrayRegion(word, 0, wordLength, wordCodePoints); // Use 1 for count to indicate the ngram has inputted. - const NgramProperty ngramProperty(CodePointArrayView(wordCodePoints, wordLength).toVector(), + const NgramProperty ngramProperty(ngramContext, + CodePointArrayView(wordCodePoints, wordLength).toVector(), probability, HistoricalInfo(timestamp, 0 /* level */, 1 /* count */)); - return dictionary->addNgramEntry(&ngramContext, &ngramProperty); + return dictionary->addNgramEntry(&ngramProperty); } static bool latinime_BinaryDictionary_removeNgramEntry(JNIEnv *env, jclass clazz, jlong dict, @@ -526,12 +527,12 @@ static int latinime_BinaryDictionary_addMultipleDictionaryEntries(JNIEnv *env, j if (word0) { jint bigramProbability = env->GetIntField(languageModelParam, bigramProbabilityFieldId); // Use 1 for count to indicate the bigram has inputted. - const NgramProperty ngramProperty( - CodePointArrayView(word1CodePoints, word1Length).toVector(), - bigramProbability, HistoricalInfo(timestamp, 0 /* level */, 1 /* count */)); const NgramContext ngramContext(word0CodePoints, word0Length, false /* isBeginningOfSentence */); - dictionary->addNgramEntry(&ngramContext, &ngramProperty); + const NgramProperty ngramProperty(ngramContext, + CodePointArrayView(word1CodePoints, word1Length).toVector(), + bigramProbability, HistoricalInfo(timestamp, 0 /* level */, 1 /* count */)); + dictionary->addNgramEntry(&ngramProperty); } if (dictionary->needsToRunGC(true /* mindsBlockByGC */)) { return i + 1; @@ -641,11 +642,8 @@ static bool latinime_BinaryDictionary_migrateNative(JNIEnv *env, jclass clazz, j return false; } } - const NgramContext ngramContext(wordCodePoints, wordCodePointCount, - wordProperty.getUnigramProperty()->representsBeginningOfSentence()); for (const NgramProperty &ngramProperty : *wordProperty.getNgramProperties()) { - if (!dictionaryStructureWithBufferPolicy->addNgramEntry(&ngramContext, - &ngramProperty)) { + if (!dictionaryStructureWithBufferPolicy->addNgramEntry(&ngramProperty)) { LogUtils::logToJava(env, "Cannot add ngram to the new dict."); return false; } |