Detach bigram functionarities from unigram_dictionary
Change-Id: Ie35164a5f293e5370885a1ba13d6ed7caf6000ec
diff --git a/native/src/dictionary.h b/native/src/dictionary.h
index 61f7cf0..1cd517c 100644
--- a/native/src/dictionary.h
+++ b/native/src/dictionary.h
@@ -37,7 +37,7 @@
int getBigrams(unsigned short *word, int length, int *codes, int codesSize,
unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams,
int maxAlternatives) {
- return mUnigramDictionary->getBigrams(word, length, codes, codesSize, outWords, frequencies,
+ return mBigramDictionary->getBigrams(word, length, codes, codesSize, outWords, frequencies,
maxWordLength, maxBigrams, maxAlternatives);
}
bool isValidWord(unsigned short *word, int length);
@@ -53,6 +53,7 @@
static bool getTerminal(const unsigned char *dict, int *pos);
static int getAddress(const unsigned char *dict, int *pos);
static int getFreq(const unsigned char *dict, const bool isLatestDictVersion, int *pos);
+ static int wideStrLen(unsigned short *str);
private:
bool hasBigram();
@@ -117,5 +118,14 @@
return freq;
}
+
+inline int Dictionary::wideStrLen(unsigned short *str) {
+ if (!str) return 0;
+ unsigned short *end = str;
+ while (*end)
+ end++;
+ return end - str;
+}
+
}; // namespace latinime
#endif // LATINIME_DICTIONARY_H