diff options
author | 2011-02-18 17:50:58 +0900 | |
---|---|---|
committer | 2011-02-22 15:27:06 +0900 | |
commit | a5d58497018f465080f08fbbfed35de883bc8be3 (patch) | |
tree | bbddfeca6083af2cda1bc069de6abefcbfec53d1 /java | |
parent | 050c0462dc2ada5a5afecec5b6745693c5066b85 (diff) | |
download | latinime-a5d58497018f465080f08fbbfed35de883bc8be3.tar.gz latinime-a5d58497018f465080f08fbbfed35de883bc8be3.tar.xz latinime-a5d58497018f465080f08fbbfed35de883bc8be3.zip |
Force autocorrection of matching words with different accents.
When entering a word without accents the user expects the system to
add accents automatically if there is no other matching word. This
patch ensures the accented version is promoted accordingly and
autocorrection really takes place.
Issue: 3400015
Change-Id: I8cd3db5bf131ec6844b26abecc1ecbd1d6269df4
Diffstat (limited to 'java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/Utils.java | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index 7091d9b56..149c5ca9e 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -285,13 +285,22 @@ public class Utils { // (the number of matched characters between typed word and suggested word)) // * (individual word's score which defined in the unigram dictionary, // and this score is defined in range [0, 255].) - // * (when before.length() == after.length(), - // mFullWordMultiplier (this is defined 2)) - // So, maximum original score is pow(2, before.length()) * 255 * 2 - // So, we can normalize original score by dividing this value. + // Then, the following processing is applied. + // - If the dictionary word is matched up to the point of the user entry + // (full match up to min(before.length(), after.length()) + // => Then multiply by FULL_MATCHED_WORDS_PROMOTION_RATE (this is defined 1.2) + // - If the word is a true full match except for differences in accents or + // capitalization, then treat it as if the frequency was 255. + // - If before.length() == after.length() + // => multiply by mFullWordMultiplier (this is defined 2)) + // So, maximum original score is pow(2, min(before.length(), after.length())) * 255 * 2 * 1.2 + // For historical reasons we ignore the 1.2 modifier (because the measure for a good + // autocorrection threshold was done at a time when it didn't exist). This doesn't change + // the result. + // So, we can normalize original score by dividing pow(2, min(b.l(),a.l())) * 255 * 2. private static final int MAX_INITIAL_SCORE = 255; private static final int TYPED_LETTER_MULTIPLIER = 2; - private static final int FULL_WORD_MULTIPLYER = 2; + private static final int FULL_WORD_MULTIPLIER = 2; public static double calcNormalizedScore(CharSequence before, CharSequence after, int score) { final int beforeLength = before.length(); final int afterLength = after.length(); @@ -301,7 +310,7 @@ public class Utils { // correction. final double maximumScore = MAX_INITIAL_SCORE * Math.pow(TYPED_LETTER_MULTIPLIER, Math.min(beforeLength, afterLength)) - * FULL_WORD_MULTIPLYER; + * FULL_WORD_MULTIPLIER; // add a weight based on edit distance. // distance <= max(afterLength, beforeLength) == afterLength, // so, 0 <= distance / afterLength <= 1 |