diff options
author | 2011-06-24 18:38:41 +0900 | |
---|---|---|
committer | 2011-06-24 18:38:41 +0900 | |
commit | 80a9ce76d85ff521aeb5a51d759f5ba367ffc627 (patch) | |
tree | 239ff93af9a2b5bb0271968467a212c150608e03 /native/src/dictionary.cpp | |
parent | dfd66f19edf1e1d97a0bf83dd20b99ee8bfae35e (diff) | |
parent | 52344a0788db20d12960b2481e99e990c3de1ea4 (diff) | |
download | latinime-80a9ce76d85ff521aeb5a51d759f5ba367ffc627.tar.gz latinime-80a9ce76d85ff521aeb5a51d759f5ba367ffc627.tar.xz latinime-80a9ce76d85ff521aeb5a51d759f5ba367ffc627.zip |
Merge remote-tracking branch 'goog/master' into merge
Conflicts:
java/res/xml/method.xml
Change-Id: I7b5f2232753d7159b520e5e57a0e06c51935edbd
Diffstat (limited to 'native/src/dictionary.cpp')
-rw-r--r-- | native/src/dictionary.cpp | 41 |
1 files changed, 6 insertions, 35 deletions
diff --git a/native/src/dictionary.cpp b/native/src/dictionary.cpp index d69cb2a53..9e32ee80f 100644 --- a/native/src/dictionary.cpp +++ b/native/src/dictionary.cpp @@ -53,45 +53,16 @@ bool Dictionary::hasBigram() { return ((mDict[1] & 0xFF) == 1); } -// TODO: use uint16_t instead of unsigned short bool Dictionary::isValidWord(unsigned short *word, int length) { + return mUnigramDictionary->isValidWord(word, length); +} + +int Dictionary::getBigramPosition(unsigned short *word, int length) { if (IS_LATEST_DICT_VERSION) { - return (isValidWordRec(DICTIONARY_HEADER_SIZE, word, 0, length) != NOT_VALID_WORD); + return mUnigramDictionary->getBigramPosition(DICTIONARY_HEADER_SIZE, word, 0, length); } else { - return (isValidWordRec(0, word, 0, length) != NOT_VALID_WORD); + return mUnigramDictionary->getBigramPosition(0, word, 0, length); } } -int Dictionary::isValidWordRec(int pos, unsigned short *word, int offset, int length) { - // returns address of bigram data of that word - // return -99 if not found - - int count = Dictionary::getCount(mDict, &pos); - unsigned short currentChar = (unsigned short) word[offset]; - for (int j = 0; j < count; j++) { - unsigned short c = Dictionary::getChar(mDict, &pos); - int terminal = Dictionary::getTerminal(mDict, &pos); - int childPos = Dictionary::getAddress(mDict, &pos); - if (c == currentChar) { - if (offset == length - 1) { - if (terminal) { - return (pos+1); - } - } else { - if (childPos != 0) { - int t = isValidWordRec(childPos, word, offset + 1, length); - if (t > 0) { - return t; - } - } - } - } - if (terminal) { - Dictionary::getFreq(mDict, IS_LATEST_DICT_VERSION, &pos); - } - // There could be two instances of each alphabet - upper and lower case. So continue - // looking ... - } - return NOT_VALID_WORD; -} } // namespace latinime |