aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/SuggestedWords.java
diff options
context:
space:
mode:
authorMohammadinamul Sheik <inamul@google.com>2015-03-19 16:07:04 -0700
committerMohammadinamul Sheik <inamul@google.com>2015-03-19 16:07:04 -0700
commitab5912959435c1901e268bc9766090e604f3523d (patch)
treec96ea06ed34cd88171c999ea9059bb47c10b4589 /java/src/com/android/inputmethod/latin/SuggestedWords.java
parentb56f7d8ca47e5936afe0459928bae49cae6e3615 (diff)
downloadlatinime-ab5912959435c1901e268bc9766090e604f3523d.tar.gz
latinime-ab5912959435c1901e268bc9766090e604f3523d.tar.xz
latinime-ab5912959435c1901e268bc9766090e604f3523d.zip
Add prev words context to the SuggestedWordInfo.
Bug: 19712589 Bug: 19715579 Change-Id: Ie06665cab8405455c1b0a2ff034e0bb0731c9156
Diffstat (limited to 'java/src/com/android/inputmethod/latin/SuggestedWords.java')
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestedWords.java30
1 files changed, 6 insertions, 24 deletions
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index 87fe29159..bcd4d5f69 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -17,11 +17,9 @@
package com.android.inputmethod.latin;
import android.text.TextUtils;
-import android.util.Log;
import android.view.inputmethod.CompletionInfo;
import com.android.inputmethod.annotations.UsedForTesting;
-import com.android.inputmethod.latin.common.Constants;
import com.android.inputmethod.latin.common.StringUtils;
import com.android.inputmethod.latin.define.DebugFlags;
@@ -264,6 +262,7 @@ public class SuggestedWords {
public static final int KIND_FLAG_APPROPRIATE_FOR_AUTO_CORRECTION = 0x10000000;
public final String mWord;
+ public final String mPrevWordsContext;
// The completion info from the application. Null for suggestions that don't come from
// the application (including keyboard-computed ones, so this is almost always null)
public final CompletionInfo mApplicationSpecifiedCompletionInfo;
@@ -284,6 +283,7 @@ public class SuggestedWords {
/**
* Create a new suggested word info.
* @param word The string to suggest.
+ * @param prevWordsContext previous words context.
* @param score A measure of how likely this suggestion is.
* @param kindAndFlags The kind of suggestion, as one of the above KIND_* constants with
* flags.
@@ -291,10 +291,12 @@ public class SuggestedWords {
* @param indexOfTouchPointOfSecondWord See mIndexOfTouchPointOfSecondWord.
* @param autoCommitFirstWordConfidence See mAutoCommitFirstWordConfidence.
*/
- public SuggestedWordInfo(final String word, final int score, final int kindAndFlags,
+ public SuggestedWordInfo(final String word, final String prevWordsContext,
+ final int score, final int kindAndFlags,
final Dictionary sourceDict, final int indexOfTouchPointOfSecondWord,
final int autoCommitFirstWordConfidence) {
mWord = word;
+ mPrevWordsContext = prevWordsContext;
mApplicationSpecifiedCompletionInfo = null;
mScore = score;
mKindAndFlags = kindAndFlags;
@@ -311,6 +313,7 @@ public class SuggestedWords {
*/
public SuggestedWordInfo(final CompletionInfo applicationSpecifiedCompletion) {
mWord = applicationSpecifiedCompletion.getText().toString();
+ mPrevWordsContext = "";
mApplicationSpecifiedCompletionInfo = applicationSpecifiedCompletion;
mScore = SuggestedWordInfo.MAX_SCORE;
mKindAndFlags = SuggestedWordInfo.KIND_APP_DEFINED;
@@ -429,27 +432,6 @@ public class SuggestedWords {
return isPrediction(mInputStyle);
}
- // Creates a new SuggestedWordInfo from the currently suggested words that removes all but the
- // last word of all suggestions, separated by a space. This is necessary because when we commit
- // a multiple-word suggestion, the IME only retains the last word as the composing word, and
- // we should only suggest replacements for this last word.
- // TODO: make this work with languages without spaces.
- public SuggestedWords getSuggestedWordsForLastWordOfPhraseGesture() {
- final ArrayList<SuggestedWordInfo> newSuggestions = new ArrayList<>();
- for (int i = 0; i < mSuggestedWordInfoList.size(); ++i) {
- final SuggestedWordInfo info = mSuggestedWordInfoList.get(i);
- final int indexOfLastSpace = info.mWord.lastIndexOf(Constants.CODE_SPACE) + 1;
- final String lastWord = info.mWord.substring(indexOfLastSpace);
- newSuggestions.add(new SuggestedWordInfo(lastWord, info.mScore, info.mKindAndFlags,
- info.mSourceDict, SuggestedWordInfo.NOT_AN_INDEX,
- SuggestedWordInfo.NOT_A_CONFIDENCE));
- }
- return new SuggestedWords(newSuggestions, null /* rawSuggestions */,
- newSuggestions.isEmpty() ? null : newSuggestions.get(0) /* typedWordInfo */,
- mTypedWordValid, mWillAutoCorrect, mIsObsoleteSuggestions, INPUT_STYLE_TAIL_BATCH,
- NOT_A_SEQUENCE_NUMBER);
- }
-
/**
* @return the {@link SuggestedWordInfo} which corresponds to the word that is originally
* typed by the user. Otherwise returns {@code null}. Note that gesture input is not