diff options
Diffstat (limited to 'java')
6 files changed, 13 insertions, 20 deletions
diff --git a/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java index 2a02603ca..620c553af 100644 --- a/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java @@ -161,7 +161,7 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary { * bigrams depending on locale. */ private void addName(String name) { - int len = name.codePointCount(0, name.length()); + int len = StringUtils.codePointCount(name); String prevWord = null; // TODO: Better tokenization for non-Latin writing systems for (int i = 0; i < len; i++) { @@ -171,7 +171,7 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary { i = end - 1; // Don't add single letter words, possibly confuses // capitalization of i. - final int wordLen = word.codePointCount(0, word.length()); + final int wordLen = StringUtils.codePointCount(word); if (wordLen < MAX_WORD_LENGTH && wordLen > 1) { super.addWord(word, null /* shortcut */, FREQUENCY_FOR_CONTACTS); if (!TextUtils.isEmpty(prevWord)) { @@ -260,14 +260,14 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary { * Checks if the words in a name are in the current binary dictionary. */ private boolean isNameInDictionary(String name) { - int len = name.codePointCount(0, name.length()); + int len = StringUtils.codePointCount(name); String prevWord = null; for (int i = 0; i < len; i++) { if (Character.isLetter(name.codePointAt(i))) { int end = getWordEndPosition(name, len, i); String word = name.substring(i, end); i = end - 1; - final int wordLen = word.codePointCount(0, word.length()); + final int wordLen = StringUtils.codePointCount(word); if (wordLen < MAX_WORD_LENGTH && wordLen > 1) { if (!TextUtils.isEmpty(prevWord) && mUseFirstLastBigrams) { if (!super.isValidBigramLocked(prevWord, word)) { diff --git a/java/src/com/android/inputmethod/latin/Dictionary.java b/java/src/com/android/inputmethod/latin/Dictionary.java index 99a04da72..00896c364 100644 --- a/java/src/com/android/inputmethod/latin/Dictionary.java +++ b/java/src/com/android/inputmethod/latin/Dictionary.java @@ -31,9 +31,6 @@ public abstract class Dictionary { */ protected static final int FULL_WORD_SCORE_MULTIPLIER = 2; - public static final int UNIGRAM = 0; - public static final int BIGRAM = 1; - public static final int NOT_A_PROBABILITY = -1; /** diff --git a/java/src/com/android/inputmethod/latin/LatinImeLogger.java b/java/src/com/android/inputmethod/latin/LatinImeLogger.java index dc0868e7c..e843848bc 100644 --- a/java/src/com/android/inputmethod/latin/LatinImeLogger.java +++ b/java/src/com/android/inputmethod/latin/LatinImeLogger.java @@ -71,7 +71,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang public static void onStartSuggestion(CharSequence previousWords) { } - public static void onAddSuggestedWord(String word, int typeId, int dataType) { + public static void onAddSuggestedWord(String word, String sourceDictionaryId) { } public static void onSetKeyboard(Keyboard kb) { diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index bde3a8403..8caa837ef 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -57,6 +57,7 @@ public class Suggest { // If you add a type of dictionary, increment DIC_TYPE_LAST_ID // TODO: this value seems unused. Remove it? public static final int DIC_TYPE_LAST_ID = 6; + public static final String DICT_KEY_USER_TYPED = "user_typed"; public static final String DICT_KEY_MAIN = "main"; public static final String DICT_KEY_CONTACTS = "contacts"; // User dictionary, the system-managed one. @@ -232,7 +233,7 @@ public class Suggest { ? typedWord.substring(0, typedWord.length() - mTrailingSingleQuotesCount) : typedWord; // Treating USER_TYPED as UNIGRAM suggestion for logging now. - LatinImeLogger.onAddSuggestedWord(typedWord, Suggest.DIC_USER_TYPED, Dictionary.UNIGRAM); + LatinImeLogger.onAddSuggestedWord(typedWord, DICT_KEY_USER_TYPED); if (wordComposer.size() <= 1 && isCorrectionEnabled) { // At first character typed, search only the bigrams @@ -253,8 +254,7 @@ public class Suggest { localSuggestions.addAll(dictionary.getBigrams(wordComposer, lowerPrevWord)); } for (final SuggestedWordInfo localSuggestion : localSuggestions) { - addWord(localSuggestion, dicTypeId, Dictionary.BIGRAM, - suggestionsContainer, consideredWord); + addWord(localSuggestion, key, suggestionsContainer, consideredWord); } } } @@ -278,8 +278,7 @@ public class Suggest { final ArrayList<SuggestedWordInfo> localSuggestions = dictionary.getWords( wordComposerForLookup, prevWordForBigram, proximityInfo); for (final SuggestedWordInfo suggestion : localSuggestions) { - addWord(suggestion, dicTypeId, Dictionary.UNIGRAM, - suggestionsContainer, consideredWord); + addWord(suggestion, key, suggestionsContainer, consideredWord); } } } @@ -401,10 +400,8 @@ public class Suggest { private static final SuggestedWordInfoComparator sSuggestedWordInfoComparator = new SuggestedWordInfoComparator(); - public boolean addWord(final SuggestedWordInfo wordInfo, - final int dicTypeId, final int dataType, + public boolean addWord(final SuggestedWordInfo wordInfo, final String dictTypeKey, final ArrayList<SuggestedWordInfo> suggestions, final String consideredWord) { - int dataTypeForLog = dataType; final int prefMaxSuggestions = MAX_SUGGESTIONS; final CharSequence word = wordInfo.mWord; @@ -426,8 +423,7 @@ public class Suggest { if (suggestions.size() > prefMaxSuggestions) { suggestions.remove(prefMaxSuggestions); } - LatinImeLogger.onAddSuggestedWord(transformedWordInfo.mWord.toString(), dicTypeId, - dataTypeForLog); + LatinImeLogger.onAddSuggestedWord(transformedWordInfo.mWord.toString(), dictTypeKey); return true; } diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java index 45ac9ff53..9883cd6bc 100644 --- a/java/src/com/android/inputmethod/latin/SuggestedWords.java +++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java @@ -142,7 +142,7 @@ public class SuggestedWords { mWord = word; mScore = score; mKind = kind; - mCodePointCount = mWordStr.codePointCount(0, mWordStr.length()); + mCodePointCount = StringUtils.codePointCount(mWordStr); } diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java index ca9caa1d3..bcd295d25 100644 --- a/java/src/com/android/inputmethod/latin/WordComposer.java +++ b/java/src/com/android/inputmethod/latin/WordComposer.java @@ -92,7 +92,7 @@ public class WordComposer { refreshSize(); } - public final void refreshSize() { + private final void refreshSize() { mCodePointSize = mTypedWord.codePointCount(0, mTypedWord.length()); } |