aboutsummaryrefslogtreecommitdiffstats
path: root/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2014-10-01 19:59:39 +0900
committerKeisuke Kuroyanagi <ksk@google.com>2014-10-01 19:59:39 +0900
commit29777e3a8a419c7c897637372c908566c6490e90 (patch)
tree89d963aacc4d9ad4dc6d2cfaf652f284255c81a1 /native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
parentce5fd94b9714f0b8bf3c28eef7176a30b9334bcb (diff)
downloadlatinime-29777e3a8a419c7c897637372c908566c6490e90.tar.gz
latinime-29777e3a8a419c7c897637372c908566c6490e90.tar.xz
latinime-29777e3a8a419c7c897637372c908566c6490e90.zip
Implement updateCounter() by using existing entry adding methods.
Bug: 14425059 Change-Id: I0b6cb80e1fb8f738e9c7d9e80fbc0c479546b879
Diffstat (limited to 'native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp')
-rw-r--r--native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
index 1e6baa5ec..365217a60 100644
--- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
+++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
@@ -374,7 +374,7 @@ static bool latinime_BinaryDictionary_addUnigramEntry(JNIEnv *env, jclass clazz,
// Use 1 for count to indicate the word has inputted.
const UnigramProperty unigramProperty(isBeginningOfSentence, isNotAWord,
isBlacklisted, probability, HistoricalInfo(timestamp, 0 /* level */, 1 /* count */),
- &shortcuts);
+ std::move(shortcuts));
return dictionary->addUnigramEntry(CodePointArrayView(codePoints, codePointCount),
&unigramProperty);
}
@@ -434,10 +434,16 @@ static bool latinime_BinaryDictionary_updateCounter(JNIEnv *env, jclass clazz, j
if (!dictionary) {
return false;
}
- jsize wordLength = env->GetArrayLength(word);
- int wordCodePoints[wordLength];
- env->GetIntArrayRegion(word, 0, wordLength, wordCodePoints);
- return false;
+ const PrevWordsInfo prevWordsInfo = JniDataUtils::constructPrevWordsInfo(env,
+ prevWordCodePointArrays, isBeginningOfSentenceArray,
+ env->GetArrayLength(prevWordCodePointArrays));
+ jsize codePointCount = env->GetArrayLength(word);
+ int wordCodePoints[codePointCount];
+ env->GetIntArrayRegion(word, 0, codePointCount, wordCodePoints);
+ const HistoricalInfo historicalInfo(timestamp, 0 /* level */, count);
+ return dictionary->updateCounter(&prevWordsInfo,
+ CodePointArrayView(wordCodePoints, codePointCount), isValidWord == JNI_TRUE,
+ historicalInfo);
}
// Returns how many language model params are processed.
@@ -509,7 +515,7 @@ static int latinime_BinaryDictionary_addMultipleDictionaryEntries(JNIEnv *env, j
// Use 1 for count to indicate the word has inputted.
const UnigramProperty unigramProperty(false /* isBeginningOfSentence */, isNotAWord,
isBlacklisted, unigramProbability,
- HistoricalInfo(timestamp, 0 /* level */, 1 /* count */), &shortcuts);
+ HistoricalInfo(timestamp, 0 /* level */, 1 /* count */), std::move(shortcuts));
dictionary->addUnigramEntry(CodePointArrayView(word1CodePoints, word1Length),
&unigramProperty);
if (word0) {