Remember the source dictionary for each suggestion.
Change-Id: I3c63372bd5572a479a67eaecfe8c8ea1cabc70d9main
parent
d8f0caa406
commit
24eec0fa68
|
@ -137,7 +137,7 @@ public class BinaryDictionary extends Dictionary {
|
|||
if (len > 0) {
|
||||
suggestions.add(new SuggestedWordInfo(
|
||||
new String(mOutputChars_bigrams, start, len),
|
||||
mBigramScores[j], SuggestedWordInfo.KIND_CORRECTION));
|
||||
mBigramScores[j], SuggestedWordInfo.KIND_CORRECTION, mDictType));
|
||||
}
|
||||
}
|
||||
return suggestions;
|
||||
|
@ -162,7 +162,7 @@ public class BinaryDictionary extends Dictionary {
|
|||
// TODO: actually get the kind from native code
|
||||
suggestions.add(new SuggestedWordInfo(
|
||||
new String(mOutputChars, start, len),
|
||||
mScores[j], SuggestedWordInfo.KIND_CORRECTION));
|
||||
mScores[j], SuggestedWordInfo.KIND_CORRECTION, mDictType));
|
||||
}
|
||||
}
|
||||
return suggestions;
|
||||
|
|
|
@ -34,6 +34,8 @@ public abstract class Dictionary {
|
|||
public static final int NOT_A_PROBABILITY = -1;
|
||||
|
||||
public static final String TYPE_USER_TYPED = "user_typed";
|
||||
public static final String TYPE_APPLICATION_DEFINED = "application_defined";
|
||||
public static final String TYPE_HARDCODED = "hardcoded"; // punctuation signs and such
|
||||
public static final String TYPE_MAIN = "main";
|
||||
public static final String TYPE_CONTACTS = "contacts";
|
||||
// User dictionary, the system-managed one.
|
||||
|
|
|
@ -382,7 +382,7 @@ public class ExpandableDictionary extends Dictionary {
|
|||
// the respective size of the typed word and the suggestion if it matters sometime
|
||||
// in the future.
|
||||
suggestions.add(new SuggestedWordInfo(new String(word, 0, depth + 1), finalFreq,
|
||||
SuggestedWordInfo.KIND_CORRECTION));
|
||||
SuggestedWordInfo.KIND_CORRECTION, mDictType));
|
||||
if (suggestions.size() >= Suggest.MAX_SUGGESTIONS) return false;
|
||||
}
|
||||
if (null != node.mShortcutTargets) {
|
||||
|
@ -390,7 +390,7 @@ public class ExpandableDictionary extends Dictionary {
|
|||
for (int shortcutIndex = 0; shortcutIndex < length; ++shortcutIndex) {
|
||||
final char[] shortcut = node.mShortcutTargets.get(shortcutIndex);
|
||||
suggestions.add(new SuggestedWordInfo(new String(shortcut, 0, shortcut.length),
|
||||
finalFreq, SuggestedWordInfo.KIND_SHORTCUT));
|
||||
finalFreq, SuggestedWordInfo.KIND_SHORTCUT, mDictType));
|
||||
if (suggestions.size() > Suggest.MAX_SUGGESTIONS) return false;
|
||||
}
|
||||
}
|
||||
|
@ -665,7 +665,7 @@ public class ExpandableDictionary extends Dictionary {
|
|||
if (freq >= 0) {
|
||||
suggestions.add(new SuggestedWordInfo(new String(mLookedUpString, index,
|
||||
BinaryDictionary.MAX_WORD_LENGTH - index),
|
||||
freq, SuggestedWordInfo.KIND_CORRECTION));
|
||||
freq, SuggestedWordInfo.KIND_CORRECTION, mDictType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,7 +179,8 @@ public class SettingsValues {
|
|||
if (puncs != null) {
|
||||
for (final String puncSpec : puncs) {
|
||||
puncList.add(new SuggestedWordInfo(KeySpecParser.getLabel(puncSpec),
|
||||
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_HARDCODED));
|
||||
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_HARDCODED,
|
||||
Dictionary.TYPE_HARDCODED));
|
||||
}
|
||||
}
|
||||
return new SuggestedWords(puncList,
|
||||
|
|
|
@ -201,7 +201,6 @@ public class Suggest {
|
|||
final String consideredWord = mTrailingSingleQuotesCount > 0
|
||||
? typedWord.substring(0, typedWord.length() - mTrailingSingleQuotesCount)
|
||||
: typedWord;
|
||||
// Treating USER_TYPED as UNIGRAM suggestion for logging now.
|
||||
LatinImeLogger.onAddSuggestedWord(typedWord, Dictionary.TYPE_USER_TYPED);
|
||||
|
||||
if (wordComposer.size() <= 1 && isCorrectionEnabled) {
|
||||
|
@ -272,16 +271,19 @@ public class Suggest {
|
|||
sb.appendCodePoint(Keyboard.CODE_SINGLE_QUOTE);
|
||||
}
|
||||
suggestionsContainer.add(0, new SuggestedWordInfo(sb.toString(),
|
||||
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_WHITELIST));
|
||||
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_WHITELIST,
|
||||
Dictionary.TYPE_WHITELIST));
|
||||
} else {
|
||||
suggestionsContainer.add(0, new SuggestedWordInfo(whitelistedWord,
|
||||
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_WHITELIST));
|
||||
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_WHITELIST,
|
||||
Dictionary.TYPE_WHITELIST));
|
||||
}
|
||||
}
|
||||
|
||||
if (!isPrediction) {
|
||||
suggestionsContainer.add(0, new SuggestedWordInfo(typedWord,
|
||||
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_TYPED));
|
||||
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_TYPED,
|
||||
Dictionary.TYPE_USER_TYPED));
|
||||
}
|
||||
SuggestedWordInfo.removeDups(suggestionsContainer);
|
||||
|
||||
|
@ -403,7 +405,7 @@ public class Suggest {
|
|||
for (int i = trailingSingleQuotesCount - 1; i >= 0; --i) {
|
||||
sb.appendCodePoint(Keyboard.CODE_SINGLE_QUOTE);
|
||||
}
|
||||
return new SuggestedWordInfo(sb, wordInfo.mScore, wordInfo.mKind);
|
||||
return new SuggestedWordInfo(sb, wordInfo.mScore, wordInfo.mKind, wordInfo.mSourceDict);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
|
|
|
@ -92,7 +92,7 @@ public class SuggestedWords {
|
|||
for (CompletionInfo info : infos) {
|
||||
if (null != info && info.getText() != null) {
|
||||
result.add(new SuggestedWordInfo(info.getText(), SuggestedWordInfo.MAX_SCORE,
|
||||
SuggestedWordInfo.KIND_APP_DEFINED));
|
||||
SuggestedWordInfo.KIND_APP_DEFINED, Dictionary.TYPE_APPLICATION_DEFINED));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -105,7 +105,7 @@ public class SuggestedWords {
|
|||
final ArrayList<SuggestedWordInfo> suggestionsList = new ArrayList<SuggestedWordInfo>();
|
||||
final HashSet<String> alreadySeen = new HashSet<String>();
|
||||
suggestionsList.add(new SuggestedWordInfo(typedWord, SuggestedWordInfo.MAX_SCORE,
|
||||
SuggestedWordInfo.KIND_TYPED));
|
||||
SuggestedWordInfo.KIND_TYPED, Dictionary.TYPE_USER_TYPED));
|
||||
alreadySeen.add(typedWord.toString());
|
||||
final int previousSize = previousSuggestions.size();
|
||||
for (int pos = 1; pos < previousSize; pos++) {
|
||||
|
@ -135,13 +135,16 @@ public class SuggestedWords {
|
|||
public final int mScore;
|
||||
public final int mKind; // one of the KIND_* constants above
|
||||
public final int mCodePointCount;
|
||||
public final String mSourceDict;
|
||||
private String mDebugString = "";
|
||||
|
||||
public SuggestedWordInfo(final CharSequence word, final int score, final int kind) {
|
||||
public SuggestedWordInfo(final CharSequence word, final int score, final int kind,
|
||||
final String sourceDict) {
|
||||
mWordStr = word.toString();
|
||||
mWord = word;
|
||||
mScore = score;
|
||||
mKind = kind;
|
||||
mSourceDict = sourceDict;
|
||||
mCodePointCount = StringUtils.codePointCount(mWordStr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue