am 68b392cc: am d24f9397: Merge "Make shortcut-only user dict entry non-words."

* commit '68b392cc1208036df06ca2c94176b2bc3b5a690d':
  Make shortcut-only user dict entry non-words.
main
Jean Chalard 2013-04-17 19:41:17 -07:00 committed by Android Git Automerger
commit 5351510dea
3 changed files with 8 additions and 6 deletions

View File

@ -173,7 +173,8 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
// capitalization of i. // capitalization of i.
final int wordLen = StringUtils.codePointCount(word); final int wordLen = StringUtils.codePointCount(word);
if (wordLen < MAX_WORD_LENGTH && wordLen > 1) { if (wordLen < MAX_WORD_LENGTH && wordLen > 1) {
super.addWord(word, null /* shortcut */, FREQUENCY_FOR_CONTACTS); super.addWord(word, null /* shortcut */, FREQUENCY_FOR_CONTACTS,
false /* isNotAWord */);
if (!TextUtils.isEmpty(prevWord)) { if (!TextUtils.isEmpty(prevWord)) {
if (mUseFirstLastBigrams) { if (mUseFirstLastBigrams) {
super.setBigram(prevWord, word, FREQUENCY_FOR_CONTACTS_BIGRAM); super.setBigram(prevWord, word, FREQUENCY_FOR_CONTACTS_BIGRAM);

View File

@ -176,14 +176,15 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
*/ */
// TODO: Create "cache dictionary" to cache fresh words for frequently updated dictionaries, // TODO: Create "cache dictionary" to cache fresh words for frequently updated dictionaries,
// considering performance regression. // considering performance regression.
protected void addWord(final String word, final String shortcutTarget, final int frequency) { protected void addWord(final String word, final String shortcutTarget, final int frequency,
final boolean isNotAWord) {
if (shortcutTarget == null) { if (shortcutTarget == null) {
mFusionDictionary.add(word, frequency, null, false /* isNotAWord */); mFusionDictionary.add(word, frequency, null, isNotAWord);
} else { } else {
// TODO: Do this in the subclass, with this class taking an arraylist. // TODO: Do this in the subclass, with this class taking an arraylist.
final ArrayList<WeightedString> shortcutTargets = CollectionUtils.newArrayList(); final ArrayList<WeightedString> shortcutTargets = CollectionUtils.newArrayList();
shortcutTargets.add(new WeightedString(shortcutTarget, frequency)); shortcutTargets.add(new WeightedString(shortcutTarget, frequency));
mFusionDictionary.add(word, frequency, shortcutTargets, false /* isNotAWord */); mFusionDictionary.add(word, frequency, shortcutTargets, isNotAWord);
} }
} }

View File

@ -258,10 +258,10 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
final int adjustedFrequency = scaleFrequencyFromDefaultToLatinIme(frequency); final int adjustedFrequency = scaleFrequencyFromDefaultToLatinIme(frequency);
// Safeguard against adding really long words. // Safeguard against adding really long words.
if (word.length() < MAX_WORD_LENGTH) { if (word.length() < MAX_WORD_LENGTH) {
super.addWord(word, null, adjustedFrequency); super.addWord(word, null, adjustedFrequency, false /* isNotAWord */);
} }
if (null != shortcut && shortcut.length() < MAX_WORD_LENGTH) { if (null != shortcut && shortcut.length() < MAX_WORD_LENGTH) {
super.addWord(shortcut, word, adjustedFrequency); super.addWord(shortcut, word, adjustedFrequency, true /* isNotAWord */);
} }
cursor.moveToNext(); cursor.moveToNext();
} }