am 3f15c41d: Merge "[AC1] Add a memory of where to cut the first word."
* commit '3f15c41d88c1060642cec87f02c3cdfd5b4c1cb8': [AC1] Add a memory of where to cut the first word.main
commit
197a883f56
|
@ -179,7 +179,8 @@ public final class BinaryDictionary extends Dictionary {
|
||||||
// TODO: check that all users of the `kind' parameter are ready to accept
|
// TODO: check that all users of the `kind' parameter are ready to accept
|
||||||
// flags too and pass mOutputTypes[j] instead of kind
|
// flags too and pass mOutputTypes[j] instead of kind
|
||||||
suggestions.add(new SuggestedWordInfo(new String(mOutputCodePoints, start, len),
|
suggestions.add(new SuggestedWordInfo(new String(mOutputCodePoints, start, len),
|
||||||
score, kind, mDictType));
|
score, kind, mDictType,
|
||||||
|
mSpaceIndices[0] /* indexOfTouchPointOfSecondWord */));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return suggestions;
|
return suggestions;
|
||||||
|
|
|
@ -403,7 +403,8 @@ public class ExpandableDictionary extends Dictionary {
|
||||||
// the respective size of the typed word and the suggestion if it matters sometime
|
// the respective size of the typed word and the suggestion if it matters sometime
|
||||||
// in the future.
|
// in the future.
|
||||||
suggestions.add(new SuggestedWordInfo(new String(word, 0, depth + 1), finalFreq,
|
suggestions.add(new SuggestedWordInfo(new String(word, 0, depth + 1), finalFreq,
|
||||||
SuggestedWordInfo.KIND_CORRECTION, mDictType));
|
SuggestedWordInfo.KIND_CORRECTION, mDictType,
|
||||||
|
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */));
|
||||||
if (suggestions.size() >= Suggest.MAX_SUGGESTIONS) return false;
|
if (suggestions.size() >= Suggest.MAX_SUGGESTIONS) return false;
|
||||||
}
|
}
|
||||||
if (null != node.mShortcutTargets) {
|
if (null != node.mShortcutTargets) {
|
||||||
|
@ -411,7 +412,8 @@ public class ExpandableDictionary extends Dictionary {
|
||||||
for (int shortcutIndex = 0; shortcutIndex < length; ++shortcutIndex) {
|
for (int shortcutIndex = 0; shortcutIndex < length; ++shortcutIndex) {
|
||||||
final char[] shortcut = node.mShortcutTargets.get(shortcutIndex);
|
final char[] shortcut = node.mShortcutTargets.get(shortcutIndex);
|
||||||
suggestions.add(new SuggestedWordInfo(new String(shortcut, 0, shortcut.length),
|
suggestions.add(new SuggestedWordInfo(new String(shortcut, 0, shortcut.length),
|
||||||
finalFreq, SuggestedWordInfo.KIND_SHORTCUT, mDictType));
|
finalFreq, SuggestedWordInfo.KIND_SHORTCUT, mDictType,
|
||||||
|
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */));
|
||||||
if (suggestions.size() > Suggest.MAX_SUGGESTIONS) return false;
|
if (suggestions.size() > Suggest.MAX_SUGGESTIONS) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -657,7 +659,8 @@ public class ExpandableDictionary extends Dictionary {
|
||||||
if (freq >= 0 && node == null) {
|
if (freq >= 0 && node == null) {
|
||||||
suggestions.add(new SuggestedWordInfo(new String(mLookedUpString, index,
|
suggestions.add(new SuggestedWordInfo(new String(mLookedUpString, index,
|
||||||
Constants.DICTIONARY_MAX_WORD_LENGTH - index),
|
Constants.DICTIONARY_MAX_WORD_LENGTH - index),
|
||||||
freq, SuggestedWordInfo.KIND_CORRECTION, mDictType));
|
freq, SuggestedWordInfo.KIND_CORRECTION, mDictType,
|
||||||
|
SuggestedWordInfo.NOT_AN_INDEX));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2614,7 +2614,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
if (!TextUtils.equals(s, typedWord)) {
|
if (!TextUtils.equals(s, typedWord)) {
|
||||||
suggestions.add(new SuggestedWordInfo(s,
|
suggestions.add(new SuggestedWordInfo(s,
|
||||||
SuggestionStripView.MAX_SUGGESTIONS - i,
|
SuggestionStripView.MAX_SUGGESTIONS - i,
|
||||||
SuggestedWordInfo.KIND_RESUMED, Dictionary.TYPE_RESUMED));
|
SuggestedWordInfo.KIND_RESUMED, Dictionary.TYPE_RESUMED,
|
||||||
|
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,7 +309,8 @@ public final class Suggest {
|
||||||
if (!TextUtils.isEmpty(typedWord)) {
|
if (!TextUtils.isEmpty(typedWord)) {
|
||||||
suggestionsContainer.add(0, new SuggestedWordInfo(typedWord,
|
suggestionsContainer.add(0, new SuggestedWordInfo(typedWord,
|
||||||
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_TYPED,
|
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_TYPED,
|
||||||
Dictionary.TYPE_USER_TYPED));
|
Dictionary.TYPE_USER_TYPED,
|
||||||
|
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */));
|
||||||
}
|
}
|
||||||
SuggestedWordInfo.removeDups(suggestionsContainer);
|
SuggestedWordInfo.removeDups(suggestionsContainer);
|
||||||
|
|
||||||
|
@ -453,7 +454,7 @@ public final class Suggest {
|
||||||
sb.appendCodePoint(Constants.CODE_SINGLE_QUOTE);
|
sb.appendCodePoint(Constants.CODE_SINGLE_QUOTE);
|
||||||
}
|
}
|
||||||
return new SuggestedWordInfo(sb.toString(), wordInfo.mScore, wordInfo.mKind,
|
return new SuggestedWordInfo(sb.toString(), wordInfo.mScore, wordInfo.mKind,
|
||||||
wordInfo.mSourceDict);
|
wordInfo.mSourceDict, wordInfo.mIndexOfTouchPointOfSecondWord);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
|
|
|
@ -113,7 +113,8 @@ public final class SuggestedWords {
|
||||||
if (null == text) continue;
|
if (null == text) continue;
|
||||||
final SuggestedWordInfo suggestedWordInfo = new SuggestedWordInfo(text.toString(),
|
final SuggestedWordInfo suggestedWordInfo = new SuggestedWordInfo(text.toString(),
|
||||||
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_APP_DEFINED,
|
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_APP_DEFINED,
|
||||||
Dictionary.TYPE_APPLICATION_DEFINED);
|
Dictionary.TYPE_APPLICATION_DEFINED,
|
||||||
|
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */);
|
||||||
result.add(suggestedWordInfo);
|
result.add(suggestedWordInfo);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -126,7 +127,8 @@ public final class SuggestedWords {
|
||||||
final ArrayList<SuggestedWordInfo> suggestionsList = CollectionUtils.newArrayList();
|
final ArrayList<SuggestedWordInfo> suggestionsList = CollectionUtils.newArrayList();
|
||||||
final HashSet<String> alreadySeen = CollectionUtils.newHashSet();
|
final HashSet<String> alreadySeen = CollectionUtils.newHashSet();
|
||||||
suggestionsList.add(new SuggestedWordInfo(typedWord, SuggestedWordInfo.MAX_SCORE,
|
suggestionsList.add(new SuggestedWordInfo(typedWord, SuggestedWordInfo.MAX_SCORE,
|
||||||
SuggestedWordInfo.KIND_TYPED, Dictionary.TYPE_USER_TYPED));
|
SuggestedWordInfo.KIND_TYPED, Dictionary.TYPE_USER_TYPED,
|
||||||
|
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */));
|
||||||
alreadySeen.add(typedWord.toString());
|
alreadySeen.add(typedWord.toString());
|
||||||
final int previousSize = previousSuggestions.size();
|
final int previousSize = previousSuggestions.size();
|
||||||
for (int index = 1; index < previousSize; index++) {
|
for (int index = 1; index < previousSize; index++) {
|
||||||
|
@ -142,6 +144,7 @@ public final class SuggestedWords {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class SuggestedWordInfo {
|
public static final class SuggestedWordInfo {
|
||||||
|
public static final int NOT_AN_INDEX = -1;
|
||||||
public static final int MAX_SCORE = Integer.MAX_VALUE;
|
public static final int MAX_SCORE = Integer.MAX_VALUE;
|
||||||
public static final int KIND_MASK_KIND = 0xFF; // Mask to get only the kind
|
public static final int KIND_MASK_KIND = 0xFF; // Mask to get only the kind
|
||||||
public static final int KIND_TYPED = 0; // What user typed
|
public static final int KIND_TYPED = 0; // What user typed
|
||||||
|
@ -167,15 +170,20 @@ public final class SuggestedWords {
|
||||||
public final int mKind; // one of the KIND_* constants above
|
public final int mKind; // one of the KIND_* constants above
|
||||||
public final int mCodePointCount;
|
public final int mCodePointCount;
|
||||||
public final String mSourceDict;
|
public final String mSourceDict;
|
||||||
|
// For auto-commit. This keeps track of the index inside the touch coordinates array
|
||||||
|
// passed to native code to get suggestions for a gesture that corresponds to the first
|
||||||
|
// letter of the second word.
|
||||||
|
public final int mIndexOfTouchPointOfSecondWord;
|
||||||
private String mDebugString = "";
|
private String mDebugString = "";
|
||||||
|
|
||||||
public SuggestedWordInfo(final String word, final int score, final int kind,
|
public SuggestedWordInfo(final String word, final int score, final int kind,
|
||||||
final String sourceDict) {
|
final String sourceDict, final int indexOfTouchPointOfSecondWord) {
|
||||||
mWord = word;
|
mWord = word;
|
||||||
mScore = score;
|
mScore = score;
|
||||||
mKind = kind;
|
mKind = kind;
|
||||||
mSourceDict = sourceDict;
|
mSourceDict = sourceDict;
|
||||||
mCodePointCount = StringUtils.codePointCount(mWord);
|
mCodePointCount = StringUtils.codePointCount(mWord);
|
||||||
|
mIndexOfTouchPointOfSecondWord = indexOfTouchPointOfSecondWord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -306,7 +306,8 @@ public final class SettingsValues {
|
||||||
// TODO: Stop using KeySpceParser.getLabel().
|
// TODO: Stop using KeySpceParser.getLabel().
|
||||||
puncList.add(new SuggestedWordInfo(KeySpecParser.getLabel(puncSpec),
|
puncList.add(new SuggestedWordInfo(KeySpecParser.getLabel(puncSpec),
|
||||||
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_HARDCODED,
|
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_HARDCODED,
|
||||||
Dictionary.TYPE_HARDCODED));
|
Dictionary.TYPE_HARDCODED,
|
||||||
|
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new SuggestedWords(puncList,
|
return new SuggestedWords(puncList,
|
||||||
|
|
|
@ -258,7 +258,8 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> {
|
||||||
|
|
||||||
protected void pickSuggestionManually(final int index, final String suggestion) {
|
protected void pickSuggestionManually(final int index, final String suggestion) {
|
||||||
mLatinIME.pickSuggestionManually(index, new SuggestedWordInfo(suggestion, 1,
|
mLatinIME.pickSuggestionManually(index, new SuggestedWordInfo(suggestion, 1,
|
||||||
SuggestedWordInfo.KIND_CORRECTION, "main"));
|
SuggestedWordInfo.KIND_CORRECTION, "main",
|
||||||
|
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper to avoid writing the try{}catch block each time
|
// Helper to avoid writing the try{}catch block each time
|
||||||
|
|
|
@ -34,9 +34,11 @@ public class SuggestedWordsTests extends AndroidTestCase {
|
||||||
final int NUMBER_OF_ADDED_SUGGESTIONS = 5;
|
final int NUMBER_OF_ADDED_SUGGESTIONS = 5;
|
||||||
final ArrayList<SuggestedWordInfo> list = CollectionUtils.newArrayList();
|
final ArrayList<SuggestedWordInfo> list = CollectionUtils.newArrayList();
|
||||||
list.add(new SuggestedWordInfo(TYPED_WORD, TYPED_WORD_FREQ,
|
list.add(new SuggestedWordInfo(TYPED_WORD, TYPED_WORD_FREQ,
|
||||||
SuggestedWordInfo.KIND_TYPED, ""));
|
SuggestedWordInfo.KIND_TYPED, "",
|
||||||
|
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */));
|
||||||
for (int i = 0; i < NUMBER_OF_ADDED_SUGGESTIONS; ++i) {
|
for (int i = 0; i < NUMBER_OF_ADDED_SUGGESTIONS; ++i) {
|
||||||
list.add(new SuggestedWordInfo("" + i, 1, SuggestedWordInfo.KIND_CORRECTION, ""));
|
list.add(new SuggestedWordInfo("" + i, 1, SuggestedWordInfo.KIND_CORRECTION, "",
|
||||||
|
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */));
|
||||||
}
|
}
|
||||||
|
|
||||||
final SuggestedWords words = new SuggestedWords(
|
final SuggestedWords words = new SuggestedWords(
|
||||||
|
|
Loading…
Reference in New Issue