diff options
author | 2013-05-15 11:04:51 -0700 | |
---|---|---|
committer | 2013-05-15 11:04:51 -0700 | |
commit | 5ca33bdc5b48e90c313350baf7ad3e8c45ac4f8c (patch) | |
tree | e2e56d1d3f61fe6fd6b6dd496f62261bde04351a /native/jni/src/suggest/core/suggest.cpp | |
parent | fa51a86b314fe75f7766bc1055c5f2d93eaadd58 (diff) | |
parent | 12b35158efe759c772454059b69615b6c6b6b854 (diff) | |
download | latinime-5ca33bdc5b48e90c313350baf7ad3e8c45ac4f8c.tar.gz latinime-5ca33bdc5b48e90c313350baf7ad3e8c45ac4f8c.tar.xz latinime-5ca33bdc5b48e90c313350baf7ad3e8c45ac4f8c.zip |
am 12b35158: am 1919072c: Merge "[ZF1] Check profanity in Java rather than in native"
* commit '12b35158efe759c772454059b69615b6c6b6b854':
[ZF1] Check profanity in Java rather than in native
Diffstat (limited to 'native/jni/src/suggest/core/suggest.cpp')
-rw-r--r-- | native/jni/src/suggest/core/suggest.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/native/jni/src/suggest/core/suggest.cpp b/native/jni/src/suggest/core/suggest.cpp index 0cf4e4a68..b1a5ff24e 100644 --- a/native/jni/src/suggest/core/suggest.cpp +++ b/native/jni/src/suggest/core/suggest.cpp @@ -161,12 +161,15 @@ int Suggest::outputSuggestions(DicTraverseSession *traverseSession, int *frequen + doubleLetterCost; const TerminalAttributes terminalAttributes(traverseSession->getOffsetDict(), terminalDicNode->getFlags(), terminalDicNode->getAttributesPos()); - const int originalTerminalProbability = terminalDicNode->getProbability(); + const bool isPossiblyOffensiveWord = terminalDicNode->getProbability() <= 0; + const bool isExactMatch = terminalDicNode->isExactMatch(); + const int outputTypeFlags = + isPossiblyOffensiveWord ? Dictionary::KIND_FLAG_POSSIBLY_OFFENSIVE : 0 + | isExactMatch ? 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(); - // Do not suggest words with a 0 probability, or entries that are blacklisted or do not - // represent a word. However, we should still submit their shortcuts if any. - const bool isValidWord = - originalTerminalProbability > 0 && !terminalAttributes.isBlacklistedOrNotAWord(); // Increase output score of top typing suggestion to ensure autocorrection. // TODO: Better integration with java side autocorrection logic. // Force autocorrection for obvious long multi-word suggestions. @@ -188,10 +191,9 @@ int Suggest::outputSuggestions(DicTraverseSession *traverseSession, int *frequen } } - // Do not suggest words with a 0 probability, or entries that are blacklisted or do not - // represent a word. However, we should still submit their shortcuts if any. + // Don't output invalid words. However, we still need to submit their shortcuts if any. if (isValidWord) { - outputTypes[outputWordIndex] = Dictionary::KIND_CORRECTION; + outputTypes[outputWordIndex] = Dictionary::KIND_CORRECTION | outputTypeFlags; frequencies[outputWordIndex] = finalScore; // Populate the outputChars array with the suggested word. const int startIndex = outputWordIndex * MAX_WORD_LENGTH; |