aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-03-09 21:33:47 +0900
committerJean Chalard <jchalard@google.com>2012-03-09 21:37:44 +0900
commit151d5cb5326f90d4f5856ebb3bb5ce338229ce7f (patch)
tree2b63769faa1e30d6a2d6c1b2090ac65af2503990 /java/src
parent36c1b379144bcb7e5a46e3ffb8817075d4f73ff3 (diff)
downloadlatinime-151d5cb5326f90d4f5856ebb3bb5ce338229ce7f.tar.gz
latinime-151d5cb5326f90d4f5856ebb3bb5ce338229ce7f.tar.xz
latinime-151d5cb5326f90d4f5856ebb3bb5ce338229ce7f.zip
Extract a condition from a method
Change-Id: I6b0262fe7cb3f7a31cc19d724c301467be932640
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java15
1 files changed, 4 insertions, 11 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index ce84a3ab2..1112baa71 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -454,8 +454,8 @@ public class Suggest implements Dictionary.WordCallback {
autoCorrectionAvailable &= !wordComposer.isMostlyCaps();
builder.setTypedWordValid(!allowsToBeAutoCorrected).setHasMinimalSuggestion(
autoCorrectionAvailable);
- if (Suggest.shouldBlockAutoCorrectionBySafetyNet(builder, mAutoCorrectionThreshold,
- !allowsToBeAutoCorrected)) {
+ if (allowsToBeAutoCorrected && builder.size() > 1 && mAutoCorrectionThreshold > 0
+ && Suggest.shouldBlockAutoCorrectionBySafetyNet(builder)) {
builder.setShouldBlockAutoCorrectionBySafetyNet();
}
return builder;
@@ -609,18 +609,11 @@ public class Suggest implements Dictionary.WordCallback {
// TODO: Resolve the inconsistencies between the native auto correction algorithms and
// this safety net
public static boolean shouldBlockAutoCorrectionBySafetyNet(
- final SuggestedWords.Builder suggestedWordsBuilder,
- final double autoCorrectionThreshold, final boolean isTypedWordValid) {
+ final SuggestedWords.Builder suggestedWordsBuilder) {
// Safety net for auto correction.
- // Actually if we hit this safety net, it's actually a bug.
- if (suggestedWordsBuilder.size() <= 1 || isTypedWordValid) {
- return false;
- }
+ // Actually if we hit this safety net, it's a bug.
// If user selected aggressive auto correction mode, there is no need to use the safety
// net.
- if (0 == autoCorrectionThreshold) {
- return false;
- }
final CharSequence typedWord = suggestedWordsBuilder.getWord(0);
// If the length of typed word is less than MINIMUM_SAFETY_NET_CHAR_LENGTH,
// we should not use net because relatively edit distance can be big.