diff options
Diffstat (limited to 'native')
-rw-r--r-- | native/jni/src/bigram_dictionary.cpp | 5 | ||||
-rw-r--r-- | native/jni/src/dictionary.h | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/native/jni/src/bigram_dictionary.cpp b/native/jni/src/bigram_dictionary.cpp index 87ca1e9ed..320b0af68 100644 --- a/native/jni/src/bigram_dictionary.cpp +++ b/native/jni/src/bigram_dictionary.cpp @@ -30,7 +30,6 @@ BigramDictionary::BigramDictionary(const unsigned char *dict, int maxWordLength, : DICT(dict), MAX_WORD_LENGTH(maxWordLength), mParentDictionary(parentDictionary) { if (DEBUG_DICT) { AKLOGI("BigramDictionary - constructor"); - AKLOGI("Has Bigram : %d", hasBigram); } } @@ -109,6 +108,8 @@ int BigramDictionary::getBigrams(unsigned short *prevWord, int prevWordLength, i const uint8_t* const root = DICT; int pos = getBigramListForWord(root, prevWord, prevWordLength); + // getBigramListForWord returns 0 if this word is not in the dictionary or has no bigrams + if (0 == pos) return 0; int bigramFlags; int bigramCount = 0; do { @@ -130,6 +131,8 @@ int BigramDictionary::getBigrams(unsigned short *prevWord, int prevWordLength, i return bigramCount; } +// Returns a pointer to the start of the bigram list. +// If the word is not found or has no bigrams, this function returns 0. int BigramDictionary::getBigramListForWord(const uint8_t* const root, const unsigned short *prevWord, const int prevWordLength) { int pos = BinaryFormat::getTerminalPosition(root, prevWord, prevWordLength); diff --git a/native/jni/src/dictionary.h b/native/jni/src/dictionary.h index 5638bbf8c..66a5c2150 100644 --- a/native/jni/src/dictionary.h +++ b/native/jni/src/dictionary.h @@ -58,8 +58,6 @@ class Dictionary { static int wideStrLen(unsigned short *str); private: - bool hasBigram(); - const unsigned char *mDict; // Used only for the mmap version of dictionary loading, but we use these as dummy variables |