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/BinaryDictDecoderUtils.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/BinaryDictDecoderUtils.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java index 782ada3f4..247d81ad3 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java @@ -408,7 +408,7 @@ public final class BinaryDictDecoderUtils { private static WeightedString getWordAtPositionWithParentAddress(final DictDecoder dictDecoder, final int pos, final FormatOptions options) { int currentPos = pos; - int frequency = Integer.MIN_VALUE; + ProbabilityInfo probabilityInfo = null; final StringBuilder builder = new StringBuilder(); // the length of the path from the root to the leaf is limited by MAX_WORD_LENGTH for (int count = 0; count < FormatSpec.MAX_WORD_LENGTH; ++count) { @@ -424,13 +424,15 @@ public final class BinaryDictDecoderUtils { MakedictLog.d("Too many jumps - probably a bug"); } } while (BinaryDictIOUtils.isMovedPtNode(currentInfo.mFlags, options)); - if (Integer.MIN_VALUE == frequency) frequency = currentInfo.mFrequency; + if (probabilityInfo == null) { + probabilityInfo = currentInfo.mProbabilityInfo; + } builder.insert(0, new String(currentInfo.mCharacters, 0, currentInfo.mCharacters.length)); if (currentInfo.mParentAddress == FormatSpec.NO_PARENT_ADDRESS) break; currentPos = currentInfo.mParentAddress + currentInfo.mOriginalAddress; } - return new WeightedString(builder.toString(), frequency); + return new WeightedString(builder.toString(), probabilityInfo); } private static WeightedString getWordAtPositionWithoutParentAddress( @@ -448,7 +450,7 @@ public final class BinaryDictDecoderUtils { groupPos = info.mEndAddress; if (info.mOriginalAddress == pos) { builder.append(new String(info.mCharacters, 0, info.mCharacters.length)); - result = new WeightedString(builder.toString(), info.mFrequency); + result = new WeightedString(builder.toString(), info.mProbabilityInfo); break; // and return } if (BinaryDictIOUtils.hasChildrenAddress(info.mChildrenAddress)) { @@ -527,13 +529,13 @@ public final class BinaryDictDecoderUtils { } nodeArrayContents.add( new PtNode(info.mCharacters, shortcutTargets, bigrams, - info.mFrequency, + info.mProbabilityInfo, 0 != (info.mFlags & FormatSpec.FLAG_IS_NOT_A_WORD), 0 != (info.mFlags & FormatSpec.FLAG_IS_BLACKLISTED), children)); } else { nodeArrayContents.add( new PtNode(info.mCharacters, shortcutTargets, bigrams, - info.mFrequency, + info.mProbabilityInfo, 0 != (info.mFlags & FormatSpec.FLAG_IS_NOT_A_WORD), 0 != (info.mFlags & FormatSpec.FLAG_IS_BLACKLISTED))); } @@ -611,7 +613,7 @@ public final class BinaryDictDecoderUtils { newDict.addBlacklistEntry(wordProperty.mWord, wordProperty.mShortcutTargets, wordProperty.mIsNotAWord); } else { - newDict.add(wordProperty.mWord, wordProperty.getProbability(), + newDict.add(wordProperty.mWord, wordProperty.mProbabilityInfo, wordProperty.mShortcutTargets, wordProperty.mIsNotAWord); } } @@ -620,7 +622,7 @@ public final class BinaryDictDecoderUtils { // words that are not also registered as unigrams so we don't have to avoid // them explicitly here. for (final WeightedString bigram : wordProperty.mBigrams) { - newDict.setBigram(wordProperty.mWord, bigram.mWord, bigram.getProbability()); + newDict.setBigram(wordProperty.mWord, bigram.mWord, bigram.mProbabilityInfo); } } } |