diff options
author | 2014-02-10 15:05:08 +0900 | |
---|---|---|
committer | 2014-02-10 15:05:08 +0900 | |
commit | 8ffc631826b108423f98e3ff4d987f067cbc4e0c (patch) | |
tree | b3ed73c26dd44b2c6ba91fd65f02ea3d3e39c4b5 /java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java | |
parent | ab6a93773ba3cbe93002bc37b6b61f874fc09144 (diff) | |
download | latinime-8ffc631826b108423f98e3ff4d987f067cbc4e0c.tar.gz latinime-8ffc631826b108423f98e3ff4d987f067cbc4e0c.tar.xz latinime-8ffc631826b108423f98e3ff4d987f067cbc4e0c.zip |
Make PtNode have ProbabilityInfo instead of raw value.
Bug: 11281877
Bug: 12810574
Change-Id: Id1cda0afc74c4e30633c735729143491b2274a7b
Diffstat (limited to 'java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java index dea9f2e28..67f86d44e 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java @@ -91,21 +91,23 @@ public final class BinaryDictIOUtils { stack.pop(); continue; } - PtNodeInfo info = dictDecoder.readPtNode(p.mAddress, formatOptions); - for (int i = 0; i < info.mCharacters.length; ++i) { - pushedChars[index++] = info.mCharacters[i]; + final PtNodeInfo ptNodeInfo = dictDecoder.readPtNode(p.mAddress, formatOptions); + for (int i = 0; i < ptNodeInfo.mCharacters.length; ++i) { + pushedChars[index++] = ptNodeInfo.mCharacters[i]; } p.mPosition++; - final boolean isMovedPtNode = isMovedPtNode(info.mFlags, + final boolean isMovedPtNode = isMovedPtNode(ptNodeInfo.mFlags, formatOptions); - final boolean isDeletedPtNode = isDeletedPtNode(info.mFlags, + final boolean isDeletedPtNode = isDeletedPtNode(ptNodeInfo.mFlags, formatOptions); - if (!isMovedPtNode && !isDeletedPtNode - && info.mFrequency != FusionDictionary.PtNode.NOT_A_TERMINAL) {// found word - words.put(info.mOriginalAddress, new String(pushedChars, 0, index)); - frequencies.put(info.mOriginalAddress, info.mFrequency); - if (info.mBigrams != null) bigrams.put(info.mOriginalAddress, info.mBigrams); + if (!isMovedPtNode && !isDeletedPtNode && ptNodeInfo.isTerminal()) {// found word + words.put(ptNodeInfo.mOriginalAddress, new String(pushedChars, 0, index)); + frequencies.put( + ptNodeInfo.mOriginalAddress, ptNodeInfo.mProbabilityInfo.mProbability); + if (ptNodeInfo.mBigrams != null) { + bigrams.put(ptNodeInfo.mOriginalAddress, ptNodeInfo.mBigrams); + } } if (p.mPosition == p.mNumOfPtNode) { @@ -127,8 +129,8 @@ public final class BinaryDictIOUtils { p.mAddress = dictDecoder.getPosition(); } - if (!isMovedPtNode && hasChildrenAddress(info.mChildrenAddress)) { - final Position childrenPos = new Position(info.mChildrenAddress, index); + if (!isMovedPtNode && hasChildrenAddress(ptNodeInfo.mChildrenAddress)) { + final Position childrenPos = new Position(ptNodeInfo.mChildrenAddress, index); stack.push(childrenPos); } } @@ -203,8 +205,7 @@ public final class BinaryDictIOUtils { if (same) { // found the PtNode matches the word. if (wordPos + currentInfo.mCharacters.length == wordLen) { - if (currentInfo.mFrequency == PtNode.NOT_A_TERMINAL - || isDeletedNode) { + if (!currentInfo.isTerminal() || isDeletedNode) { return FormatSpec.NOT_VALID_WORD; } else { return ptNodePos; |