aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Wakasa <kwakasa@google.com>2013-10-18 11:18:28 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-10-18 11:18:28 -0700
commit1c5f5eca9d6b26fd599523acb203dc4aa846bc89 (patch)
treed8845d8fdce6593a825f7251612c90bd227d4a86
parent069d44c32c95247f39fb95655dc65e740e59aabb (diff)
parent47568d5e19ed907485f7cb435c3944ccc0cb4411 (diff)
downloadlatinime-1c5f5eca9d6b26fd599523acb203dc4aa846bc89.tar.gz
latinime-1c5f5eca9d6b26fd599523acb203dc4aa846bc89.tar.xz
latinime-1c5f5eca9d6b26fd599523acb203dc4aa846bc89.zip
am 47568d5e: Merge "Fix: Suggested words from user history are invalid. DO NOT MERGE." into klp-dev
* commit '47568d5e19ed907485f7cb435c3944ccc0cb4411': Fix: Suggested words from user history are invalid. DO NOT MERGE.
-rw-r--r--java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java9
-rw-r--r--native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp11
2 files changed, 9 insertions, 11 deletions
diff --git a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java
index a1e36006b..1de15a333 100644
--- a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java
+++ b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java
@@ -114,15 +114,6 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB
}
/**
- * Return whether the passed charsequence is in the dictionary.
- */
- @Override
- public boolean isValidWord(final String word) {
- // Words included only in the user history should be treated as not in dictionary words.
- return false;
- }
-
- /**
* Pair will be added to the decaying dictionary.
*
* The first word may be null. That means we don't know the context, in other words,
diff --git a/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp b/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp
index a8ea69f3c..495b146c2 100644
--- a/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp
+++ b/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp
@@ -55,9 +55,16 @@ void DynamicPatriciaTriePolicy::createAndGetAllChildNodes(const DicNode *const d
readingHelper.initWithPtNodeArrayPos(dicNode->getChildrenPos());
const DynamicPatriciaTrieNodeReader *const nodeReader = readingHelper.getNodeReader();
while (!readingHelper.isEnd()) {
+ bool isTerminal = nodeReader->isTerminal() && !nodeReader->isDeleted();
+ if (isTerminal && mHeaderPolicy.isDecayingDict()) {
+ // A DecayingDict may have a terminal PtNode that has a terminal DicNode whose
+ // probability is NOT_A_PROBABILITY. In such case, we don't want to treat it as a
+ // valid terminal DicNode.
+ isTerminal = getProbability(nodeReader->getProbability(), NOT_A_PROBABILITY)
+ != NOT_A_PROBABILITY;
+ }
childDicNodes->pushLeavingChild(dicNode, nodeReader->getHeadPos(),
- nodeReader->getChildrenPos(), nodeReader->getProbability(),
- nodeReader->isTerminal() && !nodeReader->isDeleted(),
+ nodeReader->getChildrenPos(), nodeReader->getProbability(), isTerminal,
nodeReader->hasChildren(), nodeReader->isBlacklisted() || nodeReader->isNotAWord(),
nodeReader->getCodePointCount(), readingHelper.getMergedNodeCodePoints());
readingHelper.readNextSiblingNode();