mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Add jni method to update entries for a word efficiently.
Bug: 14425059 Change-Id: Ic628939ea68cdee17573409883a8403c73b78905
This commit is contained in:
parent
287e155e44
commit
ce5fd94b97
@ -199,6 +199,9 @@ public final class BinaryDictionary extends Dictionary {
|
||||
int[] word, int probability, int timestamp);
|
||||
private static native boolean removeNgramEntryNative(long dict,
|
||||
int[][] prevWordCodePointArrays, boolean[] isBeginningOfSentenceArray, int[] word);
|
||||
private static native boolean updateCounterNative(long dict,
|
||||
int[][] prevWordCodePointArrays, boolean[] isBeginningOfSentenceArray,
|
||||
int[] word, boolean isValidWord, int count, int timestamp);
|
||||
private static native int addMultipleDictionaryEntriesNative(long dict,
|
||||
LanguageModelParam[] languageModelParams, int startIndex);
|
||||
private static native String getPropertyNative(long dict, String query);
|
||||
|
@ -427,6 +427,19 @@ static bool latinime_BinaryDictionary_removeNgramEntry(JNIEnv *env, jclass clazz
|
||||
CodePointArrayView(wordCodePoints, codePointCount));
|
||||
}
|
||||
|
||||
static bool latinime_BinaryDictionary_updateCounter(JNIEnv *env, jclass clazz, jlong dict,
|
||||
jobjectArray prevWordCodePointArrays, jbooleanArray isBeginningOfSentenceArray,
|
||||
jintArray word, jboolean isValidWord, jint count, jint timestamp) {
|
||||
Dictionary *dictionary = reinterpret_cast<Dictionary *>(dict);
|
||||
if (!dictionary) {
|
||||
return false;
|
||||
}
|
||||
jsize wordLength = env->GetArrayLength(word);
|
||||
int wordCodePoints[wordLength];
|
||||
env->GetIntArrayRegion(word, 0, wordLength, wordCodePoints);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns how many language model params are processed.
|
||||
static int latinime_BinaryDictionary_addMultipleDictionaryEntries(JNIEnv *env, jclass clazz,
|
||||
jlong dict, jobjectArray languageModelParams, jint startIndex) {
|
||||
@ -724,6 +737,11 @@ static const JNINativeMethod sMethods[] = {
|
||||
const_cast<char *>("(J[[I[Z[I)Z"),
|
||||
reinterpret_cast<void *>(latinime_BinaryDictionary_removeNgramEntry)
|
||||
},
|
||||
{
|
||||
const_cast<char *>("updateCounterNative"),
|
||||
const_cast<char *>("(J[[I[Z[IZII)Z"),
|
||||
reinterpret_cast<void *>(latinime_BinaryDictionary_updateCounter)
|
||||
},
|
||||
{
|
||||
const_cast<char *>("addMultipleDictionaryEntriesNative"),
|
||||
const_cast<char *>(
|
||||
|
Loading…
Reference in New Issue
Block a user