From 6a442663d600fa1d8cc0b7a77f313b0a13a4b809 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Wed, 16 Dec 2009 19:21:11 -0800 Subject: [PATCH] Fix for auto-add and reduced auto-add threshold. Bug: 2332071 Fixed the regression of auto-add. Reduced the threshold of auto-add (to accept) to 2 times. Reduced the threshold of auto-add (to suggest) to 4 times. --- src/com/android/inputmethod/latin/LatinIME.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/com/android/inputmethod/latin/LatinIME.java b/src/com/android/inputmethod/latin/LatinIME.java index 1a08b2c0a..f95ca1cbb 100644 --- a/src/com/android/inputmethod/latin/LatinIME.java +++ b/src/com/android/inputmethod/latin/LatinIME.java @@ -1291,7 +1291,7 @@ public class LatinIME extends InputMethodService // If the user touches a typed word 2 times or more, it will become valid. private static final int VALIDITY_THRESHOLD = 2 * FREQUENCY_FOR_PICKED; // If the user touches a typed word 5 times or more, it will be added to the user dict. - private static final int PROMOTION_THRESHOLD = 5 * FREQUENCY_FOR_PICKED; + private static final int PROMOTION_THRESHOLD = 4 * FREQUENCY_FOR_PICKED; public AutoDictionary(Context context) { super(context); @@ -1300,7 +1300,7 @@ public class LatinIME extends InputMethodService @Override public boolean isValidWord(CharSequence word) { final int frequency = getWordFrequency(word); - return frequency > VALIDITY_THRESHOLD; + return frequency >= VALIDITY_THRESHOLD; } @Override @@ -1308,9 +1308,10 @@ public class LatinIME extends InputMethodService final int length = word.length(); // Don't add very short or very long words. if (length < 2 || length > getMaxWordLength()) return; - super.addWord(word, addFrequency); - final int freq = getWordFrequency(word); - if (freq > PROMOTION_THRESHOLD) { + int freq = getWordFrequency(word); + freq = freq < 0 ? addFrequency : freq + addFrequency; + super.addWord(word, freq); + if (freq >= PROMOTION_THRESHOLD) { LatinIME.this.promoteToUserDictionary(word, FREQUENCY_FOR_AUTO_ADD); } }