aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSatoshi Kataoka <satok@google.com>2013-05-07 00:28:14 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-05-07 00:28:14 -0700
commit221d37d754d8bc6132cd23a694489901f80dfa9d (patch)
tree42ba86144e52dfce86baaac6b93749e0bf95cc0b
parentc8dcf48e022f7964015807dd7d52905ce41bdbfb (diff)
parentd430c92deb2434040a6eede58601b5ab6a26f3fe (diff)
downloadlatinime-221d37d754d8bc6132cd23a694489901f80dfa9d.tar.gz
latinime-221d37d754d8bc6132cd23a694489901f80dfa9d.tar.xz
latinime-221d37d754d8bc6132cd23a694489901f80dfa9d.zip
am d430c92d: Merge "Fix exact match profanity"
* commit 'd430c92deb2434040a6eede58601b5ab6a26f3fe': Fix exact match profanity
-rw-r--r--native/jni/src/suggest/core/suggest.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/native/jni/src/suggest/core/suggest.cpp b/native/jni/src/suggest/core/suggest.cpp
index 3221dee9c..a18794850 100644
--- a/native/jni/src/suggest/core/suggest.cpp
+++ b/native/jni/src/suggest/core/suggest.cpp
@@ -163,9 +163,14 @@ int Suggest::outputSuggestions(DicTraverseSession *traverseSession, int *frequen
terminalDicNode->getFlags(), terminalDicNode->getAttributesPos());
const bool isPossiblyOffensiveWord = terminalDicNode->getProbability() <= 0;
const bool isExactMatch = terminalDicNode->isExactMatch();
+ const bool isFirstCharUppercase = terminalDicNode->isFirstCharUppercase();
+ // Heuristic: We exclude freq=0 first-char-uppercase words from exact match.
+ // (e.g. "AMD" and "and")
+ const bool isSafeExactMatch = isExactMatch
+ && !(isPossiblyOffensiveWord && isFirstCharUppercase);
const int outputTypeFlags =
- isPossiblyOffensiveWord ? Dictionary::KIND_FLAG_POSSIBLY_OFFENSIVE : 0
- | isExactMatch ? Dictionary::KIND_FLAG_EXACT_MATCH : 0;
+ (isPossiblyOffensiveWord ? Dictionary::KIND_FLAG_POSSIBLY_OFFENSIVE : 0)
+ | (isSafeExactMatch ? Dictionary::KIND_FLAG_EXACT_MATCH : 0);
// Entries that are blacklisted or do not represent a word should not be output.
const bool isValidWord = !terminalAttributes.isBlacklistedOrNotAWord();