aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-10-09 19:32:05 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-10-09 19:32:05 -0700
commite8c011679ae2bcc880902d86bc106f37f7d9136f (patch)
tree9e983848fc561be46ab99231af2a25ede1889aeb /java/src/com/android
parente2598657c3b773ff23283b7f194a49a7d1482a70 (diff)
parente398d09a50486d1b91ce109f4bd1a7529560c634 (diff)
downloadlatinime-e8c011679ae2bcc880902d86bc106f37f7d9136f.tar.gz
latinime-e8c011679ae2bcc880902d86bc106f37f7d9136f.tar.xz
latinime-e8c011679ae2bcc880902d86bc106f37f7d9136f.zip
am e398d09a: am af75e48e: am 74577bed: Merge "Implement the heuristic for auto-commit."
* commit 'e398d09a50486d1b91ce109f4bd1a7529560c634': Implement the heuristic for auto-commit.
Diffstat (limited to 'java/src/com/android')
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionary.java19
1 files changed, 4 insertions, 15 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index d9bad7e57..541e69788 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -44,9 +44,9 @@ public final class BinaryDictionary extends Dictionary {
private static final int MAX_WORD_LENGTH = Constants.DICTIONARY_MAX_WORD_LENGTH;
// Must be equal to MAX_RESULTS in native/jni/src/defines.h
private static final int MAX_RESULTS = 18;
- // Required space count for auto commit.
- // TODO: Remove this heuristic.
- private static final int SPACE_COUNT_FOR_AUTO_COMMIT = 3;
+ // The cutoff returned by native for auto-commit confidence.
+ // Must be equal to CONFIDENCE_TO_AUTO_COMMIT in native/jni/src/defines.h
+ private static final int CONFIDENCE_TO_AUTO_COMMIT = 1000000;
@UsedForTesting
public static final String UNIGRAM_COUNT_QUERY = "UNIGRAM_COUNT";
@@ -343,18 +343,7 @@ public final class BinaryDictionary extends Dictionary {
@Override
public boolean shouldAutoCommit(final SuggestedWordInfo candidate) {
- // TODO: actually use the confidence rather than use this completely broken heuristic
- final String word = candidate.mWord;
- final int length = word.length();
- int remainingSpaces = SPACE_COUNT_FOR_AUTO_COMMIT;
- for (int i = 0; i < length; ++i) {
- // This is okay because no low-surrogate and no high-surrogate can ever match the
- // space character, so we don't need to take care of iterating on code points.
- if (Constants.CODE_SPACE == word.charAt(i)) {
- if (0 >= --remainingSpaces) return true;
- }
- }
- return false;
+ return candidate.mAutoCommitFirstWordConfidence > CONFIDENCE_TO_AUTO_COMMIT;
}
@Override