aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-04-17 08:43:32 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-04-17 08:43:32 +0000
commit3aa04c2be0f0ab38a9add28634eaad9e53d348dd (patch)
treebe23b83ce695b9ab712ebd2261a0082ebef208b2
parentab27eb700b03165cae4aba0b026849c3f86d6a09 (diff)
parent20b0c3c5a9594e98d5468460585148cb8ace2076 (diff)
downloadlatinime-3aa04c2be0f0ab38a9add28634eaad9e53d348dd.tar.gz
latinime-3aa04c2be0f0ab38a9add28634eaad9e53d348dd.tar.xz
latinime-3aa04c2be0f0ab38a9add28634eaad9e53d348dd.zip
am 20b0c3c5: Merge "Avoid lower-case version of capitalized words in user hist"
* commit '20b0c3c5a9594e98d5468460585148cb8ace2076': Avoid lower-case version of capitalized words in user hist
-rw-r--r--java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java
index 7cb218fbe..0b6258a7f 100644
--- a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java
+++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java
@@ -421,7 +421,19 @@ public class DictionaryFacilitatorForSuggest {
final String suggestionLowerCase = suggestion.toLowerCase(dictionaries.mLocale);
final String secondWord;
if (wasAutoCapitalized) {
- secondWord = suggestionLowerCase;
+ if (isValidWord(suggestion, false /* ignoreCase */)
+ && !isValidWord(suggestionLowerCase, false /* ignoreCase */)) {
+ // If the word was auto-capitalized and exists only as a capitalized word in the
+ // dictionary, then we must not downcase it before registering it. For example,
+ // the name of the contacts in start-of-sentence position would come here with the
+ // wasAutoCapitalized flag: if we downcase it, we'd register a lower-case version
+ // of that contact's name which would end up popping in suggestions.
+ secondWord = suggestion;
+ } else {
+ // If however the word is not in the dictionary, or exists as a lower-case word
+ // only, then we consider that was a lower-case word that had been auto-capitalized.
+ secondWord = suggestionLowerCase;
+ }
} else {
// HACK: We'd like to avoid adding the capitalized form of common words to the User
// History dictionary in order to avoid suggesting them until the dictionary