Loading native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp +12 −6 Original line number Diff line number Diff line Loading @@ -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); } Loading Loading @@ -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. Loading Loading @@ -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) { Loading native/jni/src/suggest/core/dictionary/dictionary.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,14 @@ bool Dictionary::removeNgramEntry(const PrevWordsInfo *const prevWordsInfo, return mDictionaryStructureWithBufferPolicy->removeNgramEntry(prevWordsInfo, codePoints); } bool Dictionary::updateCounter(const PrevWordsInfo *const prevWordsInfo, const CodePointArrayView codePoints, const bool isValidWord, const HistoricalInfo historicalInfo) { TimeKeeper::setCurrentTime(); return mDictionaryStructureWithBufferPolicy->updateCounter(prevWordsInfo, codePoints, isValidWord, historicalInfo); } bool Dictionary::flush(const char *const filePath) { TimeKeeper::setCurrentTime(); return mDictionaryStructureWithBufferPolicy->flush(filePath); Loading native/jni/src/suggest/core/dictionary/dictionary.h +5 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include "defines.h" #include "jni.h" #include "suggest/core/dictionary/ngram_listener.h" #include "suggest/core/dictionary/property/historical_info.h" #include "suggest/core/dictionary/property/word_property.h" #include "suggest/core/policy/dictionary_header_structure_policy.h" #include "suggest/core/policy/dictionary_structure_with_buffer_policy.h" Loading Loading @@ -90,6 +91,10 @@ class Dictionary { bool removeNgramEntry(const PrevWordsInfo *const prevWordsInfo, const CodePointArrayView codePoints); bool updateCounter(const PrevWordsInfo *const prevWordsInfo, const CodePointArrayView codePoints, const bool isValidWord, const HistoricalInfo historicalInfo); bool flush(const char *const filePath); bool flushWithGC(const char *const filePath); Loading native/jni/src/suggest/core/dictionary/property/ngram_property.h +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ namespace latinime { class NgramProperty { public: NgramProperty(const std::vector<int> &&targetCodePoints, const int probability, const HistoricalInfo &historicalInfo) const HistoricalInfo historicalInfo) : mTargetCodePoints(std::move(targetCodePoints)), mProbability(probability), mHistoricalInfo(historicalInfo) {} Loading native/jni/src/suggest/core/dictionary/property/unigram_property.h +10 −3 Original line number Diff line number Diff line Loading @@ -54,11 +54,18 @@ class UnigramProperty { mProbability(NOT_A_PROBABILITY), mHistoricalInfo(), mShortcuts() {} UnigramProperty(const bool representsBeginningOfSentence, const bool isNotAWord, const bool isBlacklisted, const int probability, const HistoricalInfo &historicalInfo, const std::vector<ShortcutProperty> *const shortcuts) const bool isBlacklisted, const int probability, const HistoricalInfo historicalInfo, const std::vector<ShortcutProperty> &&shortcuts) : mRepresentsBeginningOfSentence(representsBeginningOfSentence), mIsNotAWord(isNotAWord), mIsBlacklisted(isBlacklisted), mProbability(probability), mHistoricalInfo(historicalInfo), mShortcuts(*shortcuts) {} mHistoricalInfo(historicalInfo), mShortcuts(std::move(shortcuts)) {} // Without shortcuts. UnigramProperty(const bool representsBeginningOfSentence, const bool isNotAWord, const bool isBlacklisted, const int probability, const HistoricalInfo historicalInfo) : mRepresentsBeginningOfSentence(representsBeginningOfSentence), mIsNotAWord(isNotAWord), mIsBlacklisted(isBlacklisted), mProbability(probability), mHistoricalInfo(historicalInfo), mShortcuts() {} bool representsBeginningOfSentence() const { return mRepresentsBeginningOfSentence; Loading Loading
native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp +12 −6 Original line number Diff line number Diff line Loading @@ -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); } Loading Loading @@ -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. Loading Loading @@ -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) { Loading
native/jni/src/suggest/core/dictionary/dictionary.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,14 @@ bool Dictionary::removeNgramEntry(const PrevWordsInfo *const prevWordsInfo, return mDictionaryStructureWithBufferPolicy->removeNgramEntry(prevWordsInfo, codePoints); } bool Dictionary::updateCounter(const PrevWordsInfo *const prevWordsInfo, const CodePointArrayView codePoints, const bool isValidWord, const HistoricalInfo historicalInfo) { TimeKeeper::setCurrentTime(); return mDictionaryStructureWithBufferPolicy->updateCounter(prevWordsInfo, codePoints, isValidWord, historicalInfo); } bool Dictionary::flush(const char *const filePath) { TimeKeeper::setCurrentTime(); return mDictionaryStructureWithBufferPolicy->flush(filePath); Loading
native/jni/src/suggest/core/dictionary/dictionary.h +5 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include "defines.h" #include "jni.h" #include "suggest/core/dictionary/ngram_listener.h" #include "suggest/core/dictionary/property/historical_info.h" #include "suggest/core/dictionary/property/word_property.h" #include "suggest/core/policy/dictionary_header_structure_policy.h" #include "suggest/core/policy/dictionary_structure_with_buffer_policy.h" Loading Loading @@ -90,6 +91,10 @@ class Dictionary { bool removeNgramEntry(const PrevWordsInfo *const prevWordsInfo, const CodePointArrayView codePoints); bool updateCounter(const PrevWordsInfo *const prevWordsInfo, const CodePointArrayView codePoints, const bool isValidWord, const HistoricalInfo historicalInfo); bool flush(const char *const filePath); bool flushWithGC(const char *const filePath); Loading
native/jni/src/suggest/core/dictionary/property/ngram_property.h +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ namespace latinime { class NgramProperty { public: NgramProperty(const std::vector<int> &&targetCodePoints, const int probability, const HistoricalInfo &historicalInfo) const HistoricalInfo historicalInfo) : mTargetCodePoints(std::move(targetCodePoints)), mProbability(probability), mHistoricalInfo(historicalInfo) {} Loading
native/jni/src/suggest/core/dictionary/property/unigram_property.h +10 −3 Original line number Diff line number Diff line Loading @@ -54,11 +54,18 @@ class UnigramProperty { mProbability(NOT_A_PROBABILITY), mHistoricalInfo(), mShortcuts() {} UnigramProperty(const bool representsBeginningOfSentence, const bool isNotAWord, const bool isBlacklisted, const int probability, const HistoricalInfo &historicalInfo, const std::vector<ShortcutProperty> *const shortcuts) const bool isBlacklisted, const int probability, const HistoricalInfo historicalInfo, const std::vector<ShortcutProperty> &&shortcuts) : mRepresentsBeginningOfSentence(representsBeginningOfSentence), mIsNotAWord(isNotAWord), mIsBlacklisted(isBlacklisted), mProbability(probability), mHistoricalInfo(historicalInfo), mShortcuts(*shortcuts) {} mHistoricalInfo(historicalInfo), mShortcuts(std::move(shortcuts)) {} // Without shortcuts. UnigramProperty(const bool representsBeginningOfSentence, const bool isNotAWord, const bool isBlacklisted, const int probability, const HistoricalInfo historicalInfo) : mRepresentsBeginningOfSentence(representsBeginningOfSentence), mIsNotAWord(isNotAWord), mIsBlacklisted(isBlacklisted), mProbability(probability), mHistoricalInfo(historicalInfo), mShortcuts() {} bool representsBeginningOfSentence() const { return mRepresentsBeginningOfSentence; Loading