diff options
Diffstat (limited to 'native')
-rw-r--r-- | native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp | 15 | ||||
-rw-r--r-- | native/src/bigram_dictionary.cpp | 7 | ||||
-rw-r--r-- | native/src/bigram_dictionary.h | 8 | ||||
-rw-r--r-- | native/src/dictionary.cpp | 6 | ||||
-rw-r--r-- | native/src/dictionary.h | 7 | ||||
-rw-r--r-- | native/src/unigram_dictionary.cpp | 2 | ||||
-rw-r--r-- | native/src/unigram_dictionary.h | 2 |
7 files changed, 21 insertions, 26 deletions
diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp index f2878eea5..20e44c2b0 100644 --- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp +++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp @@ -45,8 +45,7 @@ void releaseDictBuf(void* dictBuf, const size_t length, int fd); static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object, jstring sourceDir, jlong dictOffset, jlong dictSize, - jint typedLetterMultiplier, jint fullWordMultiplier, jint maxWordLength, jint maxWords, - jint maxAlternatives) { + jint typedLetterMultiplier, jint fullWordMultiplier, jint maxWordLength, jint maxWords) { PROF_OPEN; PROF_START(66); const char *sourceDirChars = env->GetStringUTFChars(sourceDir, 0); @@ -119,7 +118,7 @@ static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object, #endif // USE_MMAP_FOR_DICTIONARY } else { dictionary = new Dictionary(dictBuf, dictSize, fd, adjust, typedLetterMultiplier, - fullWordMultiplier, maxWordLength, maxWords, maxAlternatives); + fullWordMultiplier, maxWordLength, maxWords); } PROF_END(66); PROF_CLOSE; @@ -155,8 +154,7 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object, static int latinime_BinaryDictionary_getBigrams(JNIEnv *env, jobject object, jlong dict, jcharArray prevWordArray, jint prevWordLength, jintArray inputArray, jint inputArraySize, - jcharArray outputArray, jintArray frequencyArray, jint maxWordLength, jint maxBigrams, - jint maxAlternatives) { + jcharArray outputArray, jintArray frequencyArray, jint maxWordLength, jint maxBigrams) { Dictionary *dictionary = (Dictionary*)dict; if (!dictionary) return 0; @@ -166,8 +164,7 @@ static int latinime_BinaryDictionary_getBigrams(JNIEnv *env, jobject object, jlo int *frequencies = env->GetIntArrayElements(frequencyArray, 0); int count = dictionary->getBigrams((unsigned short*) prevWord, prevWordLength, inputCodes, - inputArraySize, (unsigned short*) outputChars, frequencies, maxWordLength, maxBigrams, - maxAlternatives); + inputArraySize, (unsigned short*) outputChars, frequencies, maxWordLength, maxBigrams); env->ReleaseCharArrayElements(prevWordArray, prevWord, JNI_ABORT); env->ReleaseIntArrayElements(inputArray, inputCodes, JNI_ABORT); @@ -242,11 +239,11 @@ void releaseDictBuf(void* dictBuf, const size_t length, int fd) { } static JNINativeMethod sMethods[] = { - {"openNative", "(Ljava/lang/String;JJIIIII)J", (void*)latinime_BinaryDictionary_open}, + {"openNative", "(Ljava/lang/String;JJIIII)J", (void*)latinime_BinaryDictionary_open}, {"closeNative", "(J)V", (void*)latinime_BinaryDictionary_close}, {"getSuggestionsNative", "(JJ[I[I[III[C[I)I", (void*)latinime_BinaryDictionary_getSuggestions}, {"isValidWordNative", "(J[CI)Z", (void*)latinime_BinaryDictionary_isValidWord}, - {"getBigramsNative", "(J[CI[II[C[IIII)I", (void*)latinime_BinaryDictionary_getBigrams}, + {"getBigramsNative", "(J[CI[II[C[III)I", (void*)latinime_BinaryDictionary_getBigrams}, {"calcNormalizedScoreNative", "([CI[CII)D", (void*)latinime_BinaryDictionary_calcNormalizedScore}, {"editDistanceNative", "([CI[CI)I", (void*)latinime_BinaryDictionary_editDistance} diff --git a/native/src/bigram_dictionary.cpp b/native/src/bigram_dictionary.cpp index 3704c47e6..f7a3d3e60 100644 --- a/native/src/bigram_dictionary.cpp +++ b/native/src/bigram_dictionary.cpp @@ -26,10 +26,10 @@ namespace latinime { BigramDictionary::BigramDictionary(const unsigned char *dict, int maxWordLength, - int maxAlternatives, const bool isLatestDictVersion, const bool hasBigram, + const bool isLatestDictVersion, const bool hasBigram, Dictionary *parentDictionary) : DICT(dict), MAX_WORD_LENGTH(maxWordLength), - MAX_ALTERNATIVES(maxAlternatives), IS_LATEST_DICT_VERSION(isLatestDictVersion), + IS_LATEST_DICT_VERSION(isLatestDictVersion), HAS_BIGRAM(hasBigram), mParentDictionary(parentDictionary) { if (DEBUG_DICT) { AKLOGI("BigramDictionary - constructor"); @@ -92,7 +92,6 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ * bigramFreq: an array to output frequencies. * maxWordLength: the maximum size of a word. * maxBigrams: the maximum number of bigrams fitting in the bigramChars array. - * maxAlteratives: unused. * This method returns the number of bigrams this word has, for backward compatibility. * Note: this is not the number of bigrams output in the array, which is the number of * bigrams this word has WHOSE first letter also matches the letter the user typed. @@ -103,7 +102,7 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ */ int BigramDictionary::getBigrams(unsigned short *prevWord, int prevWordLength, int *codes, int codesSize, unsigned short *bigramChars, int *bigramFreq, int maxWordLength, - int maxBigrams, int maxAlternatives) { + int maxBigrams) { // TODO: remove unused arguments, and refrain from storing stuff in members of this class // TODO: have "in" arguments before "out" ones, and make out args explicit in the name mBigramFreq = bigramFreq; diff --git a/native/src/bigram_dictionary.h b/native/src/bigram_dictionary.h index 585a1866a..8132fbc59 100644 --- a/native/src/bigram_dictionary.h +++ b/native/src/bigram_dictionary.h @@ -22,11 +22,10 @@ namespace latinime { class Dictionary; class BigramDictionary { public: - BigramDictionary(const unsigned char *dict, int maxWordLength, int maxAlternatives, + BigramDictionary(const unsigned char *dict, int maxWordLength, const bool isLatestDictVersion, const bool hasBigram, Dictionary *parentDictionary); int getBigrams(unsigned short *word, int length, int *codes, int codesSize, - unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams, - int maxAlternatives); + unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams); ~BigramDictionary(); private: bool addWordBigram(unsigned short *word, int length, int frequency); @@ -39,7 +38,8 @@ class BigramDictionary { const unsigned char *DICT; const int MAX_WORD_LENGTH; - const int MAX_ALTERNATIVES; + // TODO: Re-implement proximity correction for bigram correction + static const int MAX_ALTERNATIVES = 1; const bool IS_LATEST_DICT_VERSION; const bool HAS_BIGRAM; diff --git a/native/src/dictionary.cpp b/native/src/dictionary.cpp index 8e252f730..981a983ee 100644 --- a/native/src/dictionary.cpp +++ b/native/src/dictionary.cpp @@ -27,7 +27,7 @@ namespace latinime { // TODO: Change the type of all keyCodes to uint32_t Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int typedLetterMultiplier, int fullWordMultiplier, - int maxWordLength, int maxWords, int maxAlternatives) + int maxWordLength, int maxWords) : mDict((unsigned char*) dict), mDictSize(dictSize), mMmapFd(mmapFd), mDictBufAdjust(dictBufAdjust), // Checks whether it has the latest dictionary or the old dictionary @@ -44,8 +44,8 @@ Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, maxWords, SUB_QUEUE_MAX_WORDS, maxWordLength); const unsigned int headerSize = BinaryFormat::getHeaderSize(mDict); mUnigramDictionary = new UnigramDictionary(mDict + headerSize, typedLetterMultiplier, - fullWordMultiplier, maxWordLength, maxWords, maxAlternatives, IS_LATEST_DICT_VERSION); - mBigramDictionary = new BigramDictionary(mDict + headerSize, maxWordLength, maxAlternatives, + fullWordMultiplier, maxWordLength, maxWords, IS_LATEST_DICT_VERSION); + mBigramDictionary = new BigramDictionary(mDict + headerSize, maxWordLength, IS_LATEST_DICT_VERSION, true /* hasBigram */, this); } diff --git a/native/src/dictionary.h b/native/src/dictionary.h index 90d7148d5..139d3f0d7 100644 --- a/native/src/dictionary.h +++ b/native/src/dictionary.h @@ -30,7 +30,7 @@ namespace latinime { class Dictionary { public: Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int typedLetterMultipler, - int fullWordMultiplier, int maxWordLength, int maxWords, int maxAlternatives); + int fullWordMultiplier, int maxWordLength, int maxWords); int getSuggestions(ProximityInfo *proximityInfo, int *xcoordinates, int *ycoordinates, int *codes, int codesSize, int flags, unsigned short *outWords, int *frequencies) { @@ -41,10 +41,9 @@ class Dictionary { // TODO: Call mBigramDictionary instead of mUnigramDictionary int getBigrams(unsigned short *word, int length, int *codes, int codesSize, - unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams, - int maxAlternatives) { + unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams) { return mBigramDictionary->getBigrams(word, length, codes, codesSize, outWords, frequencies, - maxWordLength, maxBigrams, maxAlternatives); + maxWordLength, maxBigrams); } bool isValidWord(unsigned short *word, int length); diff --git a/native/src/unigram_dictionary.cpp b/native/src/unigram_dictionary.cpp index d21413d8b..ed4c066f3 100644 --- a/native/src/unigram_dictionary.cpp +++ b/native/src/unigram_dictionary.cpp @@ -40,7 +40,7 @@ const UnigramDictionary::digraph_t UnigramDictionary::FRENCH_LIGATURES_DIGRAPHS[ // TODO: check the header UnigramDictionary::UnigramDictionary(const uint8_t* const streamStart, int typedLetterMultiplier, - int fullWordMultiplier, int maxWordLength, int maxWords, int maxProximityChars, + int fullWordMultiplier, int maxWordLength, int maxWords, const bool isLatestDictVersion) : DICT_ROOT(streamStart), MAX_WORD_LENGTH(maxWordLength), MAX_WORDS(maxWords), IS_LATEST_DICT_VERSION(isLatestDictVersion), diff --git a/native/src/unigram_dictionary.h b/native/src/unigram_dictionary.h index 86bda77cb..c8f15566c 100644 --- a/native/src/unigram_dictionary.h +++ b/native/src/unigram_dictionary.h @@ -74,7 +74,7 @@ class UnigramDictionary { static const int MAX_ERRORS_FOR_TWO_WORDS = 1; UnigramDictionary(const uint8_t* const streamStart, int typedLetterMultipler, - int fullWordMultiplier, int maxWordLength, int maxWords, int maxProximityChars, + int fullWordMultiplier, int maxWordLength, int maxWords, const bool isLatestDictVersion); bool isValidWord(const uint16_t* const inWord, const int length) const; int getBigramPosition(int pos, unsigned short *word, int offset, int length) const; |