aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2014-03-28 14:49:49 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-03-28 14:49:49 +0000
commite7a4330ccfdd66b31b07221fe8f0f9f613f515ce (patch)
tree3fb838b65417a8d2859f696b3f2b38a6b9163278 /java
parent82166382fdeff2a50af23b380839ea8d955ef832 (diff)
parent89df80292ea98a1430687786a9e2c1b9bf165b9d (diff)
downloadlatinime-e7a4330ccfdd66b31b07221fe8f0f9f613f515ce.tar.gz
latinime-e7a4330ccfdd66b31b07221fe8f0f9f613f515ce.tar.xz
latinime-e7a4330ccfdd66b31b07221fe8f0f9f613f515ce.zip
am 89df8029: Merge "Fix: spell checker wrongly sorts suggestions."
* commit '89df80292ea98a1430687786a9e2c1b9bf165b9d': Fix: spell checker wrongly sorts suggestions.
Diffstat (limited to 'java')
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java11
1 files changed, 4 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
index a07e8eb6a..6a52481b9 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -268,6 +268,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
// if it doesn't. See documentation for binarySearch.
final int insertIndex = positionIndex >= 0 ? positionIndex : -positionIndex - 1;
+ // Weak <- insertIndex == 0, ..., insertIndex == mLength -> Strong
if (insertIndex == 0 && mLength >= mMaxLength) {
// In the future, we may want to keep track of the best suggestion score even if
// we are asked for 0 suggestions. In this case, we can use the following
@@ -285,11 +286,6 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
// }
return true;
}
- if (insertIndex >= mMaxLength) {
- // We found a suggestion, but its score is too weak to be kept considering
- // the suggestion limit.
- return true;
- }
final String wordString = new String(word, wordOffset, wordLength);
if (mLength < mMaxLength) {
@@ -297,12 +293,13 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
++mLength;
System.arraycopy(mScores, insertIndex, mScores, insertIndex + 1, copyLen);
mSuggestions.add(insertIndex, wordString);
+ mScores[insertIndex] = score;
} else {
- System.arraycopy(mScores, 1, mScores, 0, insertIndex);
+ System.arraycopy(mScores, 1, mScores, 0, insertIndex - 1);
mSuggestions.add(insertIndex, wordString);
mSuggestions.remove(0);
+ mScores[insertIndex - 1] = score;
}
- mScores[insertIndex] = score;
return true;
}