Loading native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp +8 −6 Original line number Original line Diff line number Diff line Loading @@ -137,13 +137,15 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object, int *frequencies = env->GetIntArrayElements(frequencyArray, 0); int *frequencies = env->GetIntArrayElements(frequencyArray, 0); int *inputCodes = env->GetIntArrayElements(inputArray, 0); int *inputCodes = env->GetIntArrayElements(inputArray, 0); jchar *outputChars = env->GetCharArrayElements(outputArray, 0); jchar *outputChars = env->GetCharArrayElements(outputArray, 0); // Deactivated to prevent unused variable errors. jint *prevWordChars = prevWordForBigrams // TODO: use the following variables. ? env->GetIntArrayElements(prevWordForBigrams, 0) : 0; // jint *prevWordChars = prevWordForBigrams jsize prevWordLength = prevWordChars ? env->GetArrayLength(prevWordForBigrams) : 0; // ? env->GetIntArrayElements(prevWordForBigrams, 0) : NULL; // jsize prevWordLength = prevWordChars ? env->GetArrayLength(prevWordForBigrams) : 0; int count = dictionary->getSuggestions(pInfo, xCoordinates, yCoordinates, inputCodes, int count = dictionary->getSuggestions(pInfo, xCoordinates, yCoordinates, inputCodes, arraySize, useFullEditDistance, (unsigned short*) outputChars, frequencies); arraySize, prevWordChars, prevWordLength, useFullEditDistance, (unsigned short*) outputChars, frequencies); if (prevWordChars) { env->ReleaseIntArrayElements(prevWordForBigrams, prevWordChars, JNI_ABORT); } env->ReleaseCharArrayElements(outputArray, outputChars, 0); env->ReleaseCharArrayElements(outputArray, outputChars, 0); env->ReleaseIntArrayElements(inputArray, inputCodes, JNI_ABORT); env->ReleaseIntArrayElements(inputArray, inputCodes, JNI_ABORT); env->ReleaseIntArrayElements(frequencyArray, frequencies, 0); env->ReleaseIntArrayElements(frequencyArray, frequencies, 0); Loading native/jni/src/bigram_dictionary.cpp +5 −4 Original line number Original line Diff line number Diff line Loading @@ -107,8 +107,8 @@ int BigramDictionary::getBigrams(const int32_t *prevWord, int prevWordLength, in mMaxBigrams = maxBigrams; mMaxBigrams = maxBigrams; const uint8_t* const root = DICT; const uint8_t* const root = DICT; int pos = getBigramListForWord(root, prevWord, prevWordLength); int pos = getBigramListPositionForWord(prevWord, prevWordLength); // getBigramListForWord returns 0 if this word is not in the dictionary or has no bigrams // getBigramListPositionForWord returns 0 if this word isn't in the dictionary or has no bigrams if (0 == pos) return 0; if (0 == pos) return 0; int bigramFlags; int bigramFlags; int bigramCount = 0; int bigramCount = 0; Loading @@ -133,8 +133,9 @@ int BigramDictionary::getBigrams(const int32_t *prevWord, int prevWordLength, in // Returns a pointer to the start of the bigram list. // Returns a pointer to the start of the bigram list. // If the word is not found or has no bigrams, this function returns 0. // If the word is not found or has no bigrams, this function returns 0. int BigramDictionary::getBigramListForWord(const uint8_t* const root, int BigramDictionary::getBigramListPositionForWord(const int32_t *prevWord, const int32_t *prevWord, const int prevWordLength) { const int prevWordLength) { const uint8_t* const root = DICT; int pos = BinaryFormat::getTerminalPosition(root, prevWord, prevWordLength); int pos = BinaryFormat::getTerminalPosition(root, prevWord, prevWordLength); if (NOT_VALID_WORD == pos) return 0; if (NOT_VALID_WORD == pos) return 0; Loading native/jni/src/bigram_dictionary.h +1 −2 Original line number Original line Diff line number Diff line Loading @@ -27,8 +27,7 @@ class BigramDictionary { BigramDictionary(const unsigned char *dict, int maxWordLength, Dictionary *parentDictionary); BigramDictionary(const unsigned char *dict, int maxWordLength, Dictionary *parentDictionary); int getBigrams(const int32_t *word, int length, int *codes, int codesSize, int getBigrams(const int32_t *word, int length, int *codes, int codesSize, unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams); unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams); int getBigramListForWord(const uint8_t* const root, int getBigramListPositionForWord(const int32_t *prevWord, const int prevWordLength); const int32_t *prevWord, const int prevWordLength); ~BigramDictionary(); ~BigramDictionary(); private: private: bool addWordBigram(unsigned short *word, int length, int frequency); bool addWordBigram(unsigned short *word, int length, int frequency); Loading native/jni/src/dictionary.h +4 −4 Original line number Original line Diff line number Diff line Loading @@ -33,12 +33,12 @@ class Dictionary { int fullWordMultiplier, int maxWordLength, int maxWords); int fullWordMultiplier, int maxWordLength, int maxWords); int getSuggestions(ProximityInfo *proximityInfo, int *xcoordinates, int *ycoordinates, int getSuggestions(ProximityInfo *proximityInfo, int *xcoordinates, int *ycoordinates, int *codes, int codesSize, bool useFullEditDistance, unsigned short *outWords, int *codes, int codesSize, const int32_t* prevWordChars, const int prevWordLength, int *frequencies) { bool useFullEditDistance, unsigned short *outWords, int *frequencies) { // bigramListPosition is, as an int, the offset of the bigram list in the file. // bigramListPosition is, as an int, the offset of the bigram list in the file. // If none, it's zero. // If none, it's zero. // TODO: get this from the bigram dictionary instance const int bigramListPosition = !prevWordChars ? 0 const int bigramListPosition = 0; : mBigramDictionary->getBigramListPositionForWord(prevWordChars, prevWordLength); return mUnigramDictionary->getSuggestions(proximityInfo, mWordsPriorityQueuePool, return mUnigramDictionary->getSuggestions(proximityInfo, mWordsPriorityQueuePool, mCorrection, xcoordinates, ycoordinates, codes, codesSize, bigramListPosition, mCorrection, xcoordinates, ycoordinates, codes, codesSize, bigramListPosition, useFullEditDistance, outWords, frequencies); useFullEditDistance, outWords, frequencies); Loading Loading
native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp +8 −6 Original line number Original line Diff line number Diff line Loading @@ -137,13 +137,15 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object, int *frequencies = env->GetIntArrayElements(frequencyArray, 0); int *frequencies = env->GetIntArrayElements(frequencyArray, 0); int *inputCodes = env->GetIntArrayElements(inputArray, 0); int *inputCodes = env->GetIntArrayElements(inputArray, 0); jchar *outputChars = env->GetCharArrayElements(outputArray, 0); jchar *outputChars = env->GetCharArrayElements(outputArray, 0); // Deactivated to prevent unused variable errors. jint *prevWordChars = prevWordForBigrams // TODO: use the following variables. ? env->GetIntArrayElements(prevWordForBigrams, 0) : 0; // jint *prevWordChars = prevWordForBigrams jsize prevWordLength = prevWordChars ? env->GetArrayLength(prevWordForBigrams) : 0; // ? env->GetIntArrayElements(prevWordForBigrams, 0) : NULL; // jsize prevWordLength = prevWordChars ? env->GetArrayLength(prevWordForBigrams) : 0; int count = dictionary->getSuggestions(pInfo, xCoordinates, yCoordinates, inputCodes, int count = dictionary->getSuggestions(pInfo, xCoordinates, yCoordinates, inputCodes, arraySize, useFullEditDistance, (unsigned short*) outputChars, frequencies); arraySize, prevWordChars, prevWordLength, useFullEditDistance, (unsigned short*) outputChars, frequencies); if (prevWordChars) { env->ReleaseIntArrayElements(prevWordForBigrams, prevWordChars, JNI_ABORT); } env->ReleaseCharArrayElements(outputArray, outputChars, 0); env->ReleaseCharArrayElements(outputArray, outputChars, 0); env->ReleaseIntArrayElements(inputArray, inputCodes, JNI_ABORT); env->ReleaseIntArrayElements(inputArray, inputCodes, JNI_ABORT); env->ReleaseIntArrayElements(frequencyArray, frequencies, 0); env->ReleaseIntArrayElements(frequencyArray, frequencies, 0); Loading
native/jni/src/bigram_dictionary.cpp +5 −4 Original line number Original line Diff line number Diff line Loading @@ -107,8 +107,8 @@ int BigramDictionary::getBigrams(const int32_t *prevWord, int prevWordLength, in mMaxBigrams = maxBigrams; mMaxBigrams = maxBigrams; const uint8_t* const root = DICT; const uint8_t* const root = DICT; int pos = getBigramListForWord(root, prevWord, prevWordLength); int pos = getBigramListPositionForWord(prevWord, prevWordLength); // getBigramListForWord returns 0 if this word is not in the dictionary or has no bigrams // getBigramListPositionForWord returns 0 if this word isn't in the dictionary or has no bigrams if (0 == pos) return 0; if (0 == pos) return 0; int bigramFlags; int bigramFlags; int bigramCount = 0; int bigramCount = 0; Loading @@ -133,8 +133,9 @@ int BigramDictionary::getBigrams(const int32_t *prevWord, int prevWordLength, in // Returns a pointer to the start of the bigram list. // Returns a pointer to the start of the bigram list. // If the word is not found or has no bigrams, this function returns 0. // If the word is not found or has no bigrams, this function returns 0. int BigramDictionary::getBigramListForWord(const uint8_t* const root, int BigramDictionary::getBigramListPositionForWord(const int32_t *prevWord, const int32_t *prevWord, const int prevWordLength) { const int prevWordLength) { const uint8_t* const root = DICT; int pos = BinaryFormat::getTerminalPosition(root, prevWord, prevWordLength); int pos = BinaryFormat::getTerminalPosition(root, prevWord, prevWordLength); if (NOT_VALID_WORD == pos) return 0; if (NOT_VALID_WORD == pos) return 0; Loading
native/jni/src/bigram_dictionary.h +1 −2 Original line number Original line Diff line number Diff line Loading @@ -27,8 +27,7 @@ class BigramDictionary { BigramDictionary(const unsigned char *dict, int maxWordLength, Dictionary *parentDictionary); BigramDictionary(const unsigned char *dict, int maxWordLength, Dictionary *parentDictionary); int getBigrams(const int32_t *word, int length, int *codes, int codesSize, int getBigrams(const int32_t *word, int length, int *codes, int codesSize, unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams); unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams); int getBigramListForWord(const uint8_t* const root, int getBigramListPositionForWord(const int32_t *prevWord, const int prevWordLength); const int32_t *prevWord, const int prevWordLength); ~BigramDictionary(); ~BigramDictionary(); private: private: bool addWordBigram(unsigned short *word, int length, int frequency); bool addWordBigram(unsigned short *word, int length, int frequency); Loading
native/jni/src/dictionary.h +4 −4 Original line number Original line Diff line number Diff line Loading @@ -33,12 +33,12 @@ class Dictionary { int fullWordMultiplier, int maxWordLength, int maxWords); int fullWordMultiplier, int maxWordLength, int maxWords); int getSuggestions(ProximityInfo *proximityInfo, int *xcoordinates, int *ycoordinates, int getSuggestions(ProximityInfo *proximityInfo, int *xcoordinates, int *ycoordinates, int *codes, int codesSize, bool useFullEditDistance, unsigned short *outWords, int *codes, int codesSize, const int32_t* prevWordChars, const int prevWordLength, int *frequencies) { bool useFullEditDistance, unsigned short *outWords, int *frequencies) { // bigramListPosition is, as an int, the offset of the bigram list in the file. // bigramListPosition is, as an int, the offset of the bigram list in the file. // If none, it's zero. // If none, it's zero. // TODO: get this from the bigram dictionary instance const int bigramListPosition = !prevWordChars ? 0 const int bigramListPosition = 0; : mBigramDictionary->getBigramListPositionForWord(prevWordChars, prevWordLength); return mUnigramDictionary->getSuggestions(proximityInfo, mWordsPriorityQueuePool, return mUnigramDictionary->getSuggestions(proximityInfo, mWordsPriorityQueuePool, mCorrection, xcoordinates, ycoordinates, codes, codesSize, bigramListPosition, mCorrection, xcoordinates, ycoordinates, codes, codesSize, bigramListPosition, useFullEditDistance, outWords, frequencies); useFullEditDistance, outWords, frequencies); Loading