diff options
author | 2014-05-27 09:04:29 +0000 | |
---|---|---|
committer | 2014-05-27 09:04:29 +0000 | |
commit | 060ac3cd284e5795f08b2057223480071877ff69 (patch) | |
tree | a56270cb65f4c1e8c8c094f19975e12e85e49625 /tests/src | |
parent | 871c001525af703c22c2a74d01d38315b152465c (diff) | |
parent | 3faf4fc5e776ec055d841e0dbe436fc418a60980 (diff) | |
download | latinime-060ac3cd284e5795f08b2057223480071877ff69.tar.gz latinime-060ac3cd284e5795f08b2057223480071877ff69.tar.xz latinime-060ac3cd284e5795f08b2057223480071877ff69.zip |
am 3faf4fc5: Merge "Return whether the dynamic dict operation was success."
* commit '3faf4fc5e776ec055d841e0dbe436fc418a60980':
Return whether the dynamic dict operation was success.
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/tests/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java b/tests/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java index 0528e341e..8f32e5336 100644 --- a/tests/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java +++ b/tests/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java @@ -75,33 +75,54 @@ public class Ver4DictEncoder implements DictEncoder { for (final WordProperty wordProperty : dict) { // TODO: switch to addMultipleDictionaryEntries when they support shortcuts if (null == wordProperty.mShortcutTargets || wordProperty.mShortcutTargets.isEmpty()) { - binaryDict.addUnigramEntry(wordProperty.mWord, wordProperty.getProbability(), + if (!binaryDict.addUnigramEntry(wordProperty.mWord, wordProperty.getProbability(), null /* shortcutTarget */, 0 /* shortcutProbability */, wordProperty.mIsBeginningOfSentence, wordProperty.mIsNotAWord, - wordProperty.mIsBlacklistEntry, 0 /* timestamp */); + wordProperty.mIsBlacklistEntry, 0 /* timestamp */)) { + MakedictLog.e("Cannot add unigram entry for " + wordProperty.mWord); + } } else { for (final WeightedString shortcutTarget : wordProperty.mShortcutTargets) { - binaryDict.addUnigramEntry(wordProperty.mWord, wordProperty.getProbability(), + if (!binaryDict.addUnigramEntry(wordProperty.mWord, + wordProperty.getProbability(), shortcutTarget.mWord, shortcutTarget.getProbability(), wordProperty.mIsBeginningOfSentence, wordProperty.mIsNotAWord, - wordProperty.mIsBlacklistEntry, 0 /* timestamp */); + wordProperty.mIsBlacklistEntry, 0 /* timestamp */)) { + MakedictLog.e("Cannot add unigram entry for " + wordProperty.mWord + + ", shortcutTarget: " + shortcutTarget.mWord); + return; + } } } if (binaryDict.needsToRunGC(true /* mindsBlockByGC */)) { - binaryDict.flushWithGC(); + if (!binaryDict.flushWithGC()) { + MakedictLog.e("Cannot flush dict with GC."); + return; + } } } for (final WordProperty word0Property : dict) { if (null == word0Property.mBigrams) continue; for (final WeightedString word1 : word0Property.mBigrams) { - binaryDict.addNgramEntry(new PrevWordsInfo(word0Property.mWord), word1.mWord, - word1.getProbability(), 0 /* timestamp */); + final PrevWordsInfo prevWordsInfo = new PrevWordsInfo(word0Property.mWord); + if (!binaryDict.addNgramEntry(prevWordsInfo, word1.mWord, + word1.getProbability(), 0 /* timestamp */)) { + MakedictLog.e("Cannot add n-gram entry for " + + prevWordsInfo + " -> " + word1.mWord); + return; + } if (binaryDict.needsToRunGC(true /* mindsBlockByGC */)) { - binaryDict.flushWithGC(); + if (!binaryDict.flushWithGC()) { + MakedictLog.e("Cannot flush dict with GC."); + return; + } } } } - binaryDict.flushWithGC(); + if (!binaryDict.flushWithGC()) { + MakedictLog.e("Cannot flush dict with GC."); + return; + } binaryDict.close(); } |