From 0a7944653105f257d99e9db2d90b2bfc932ee765 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Tue, 26 Jun 2012 16:01:09 +0900 Subject: [PATCH] Remove a meaningless separation (A18) Change-Id: I267177044c7d7b0d9119839a11057b2bbf41f75f --- .../android/inputmethod/latin/Suggest.java | 35 ++++++++----------- .../AndroidSpellCheckerService.java | 9 +++-- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 3b420aab6..4e8bf1973 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -59,10 +59,8 @@ public class Suggest { public static final String DICT_KEY_CONTACTS = "contacts"; // User dictionary, the system-managed one. public static final String DICT_KEY_USER = "user"; - // User history dictionary for the unigram map, internal to LatinIME - public static final String DICT_KEY_USER_HISTORY_UNIGRAM = "history_unigram"; - // User history dictionary for the bigram map, internal to LatinIME - public static final String DICT_KEY_USER_HISTORY_BIGRAM = "history_bigram"; + // User history dictionary internal to LatinIME + public static final String DICT_KEY_USER_HISTORY = "history"; public static final String DICT_KEY_WHITELIST ="whitelist"; // TODO: remove this map. This only serves as backward compatibility with a feature // that has never been used and has been broken for a while. @@ -71,8 +69,7 @@ public class Suggest { static { sDictKeyToDictIndex.put(DICT_KEY_MAIN, DIC_MAIN); sDictKeyToDictIndex.put(DICT_KEY_USER, DIC_USER); - sDictKeyToDictIndex.put(DICT_KEY_USER_HISTORY_UNIGRAM, DIC_USER_HISTORY); - sDictKeyToDictIndex.put(DICT_KEY_USER_HISTORY_BIGRAM, DIC_USER_HISTORY); + sDictKeyToDictIndex.put(DICT_KEY_USER_HISTORY, DIC_USER_HISTORY); sDictKeyToDictIndex.put(DICT_KEY_CONTACTS, DIC_CONTACTS); sDictKeyToDictIndex.put(DICT_KEY_WHITELIST, DIC_WHITELIST); } @@ -195,10 +192,8 @@ public class Suggest { } public void setUserHistoryDictionary(UserHistoryDictionary userHistoryDictionary) { - addOrReplaceDictionary(mUnigramDictionaries, DICT_KEY_USER_HISTORY_UNIGRAM, - userHistoryDictionary); - addOrReplaceDictionary(mBigramDictionaries, DICT_KEY_USER_HISTORY_BIGRAM, - userHistoryDictionary); + addOrReplaceDictionary(mUnigramDictionaries, DICT_KEY_USER_HISTORY, userHistoryDictionary); + addOrReplaceDictionary(mBigramDictionaries, DICT_KEY_USER_HISTORY, userHistoryDictionary); } public void setAutoCorrectionThreshold(float threshold) { @@ -269,8 +264,8 @@ public class Suggest { } for (final SuggestedWordInfo suggestion : suggestions) { final String suggestionStr = suggestion.mWord.toString(); - oldAddWord(suggestionStr.toCharArray(), null, 0, suggestionStr.length(), - suggestion.mScore, dicTypeId, Dictionary.BIGRAM); + addWord(suggestionStr.toCharArray(), null, 0, suggestionStr.length(), + suggestion.mScore, dicTypeId, Dictionary.BIGRAM, mSuggestions); } } } @@ -287,7 +282,7 @@ public class Suggest { // At second character typed, search the unigrams (scores being affected by bigrams) for (final String key : mUnigramDictionaries.keySet()) { // Skip UserUnigramDictionary and WhitelistDictionary to lookup - if (key.equals(DICT_KEY_USER_HISTORY_UNIGRAM) || key.equals(DICT_KEY_WHITELIST)) + if (key.equals(DICT_KEY_USER_HISTORY) || key.equals(DICT_KEY_WHITELIST)) continue; final int dicTypeId = sDictKeyToDictIndex.get(key); final Dictionary dictionary = mUnigramDictionaries.get(key); @@ -295,8 +290,8 @@ public class Suggest { wordComposerForLookup, prevWordForBigram, proximityInfo); for (final SuggestedWordInfo suggestion : suggestions) { final String suggestionStr = suggestion.mWord.toString(); - oldAddWord(suggestionStr.toCharArray(), null, 0, suggestionStr.length(), - suggestion.mScore, dicTypeId, Dictionary.UNIGRAM); + addWord(suggestionStr.toCharArray(), null, 0, suggestionStr.length(), + suggestion.mScore, dicTypeId, Dictionary.UNIGRAM, mSuggestions); } } } @@ -404,13 +399,11 @@ public class Suggest { } // TODO: Use codepoint instead of char - public boolean oldAddWord(final char[] word, int[] indices, final int offset, final int length, - int score, final int dicTypeId, final int dataType) { + public boolean addWord(final char[] word, int[] indices, final int offset, final int length, + int score, final int dicTypeId, final int dataType, + final ArrayList suggestions) { int dataTypeForLog = dataType; - final ArrayList suggestions; - final int prefMaxSuggestions; - suggestions = mSuggestions; - prefMaxSuggestions = MAX_SUGGESTIONS; + final int prefMaxSuggestions = MAX_SUGGESTIONS; int pos = 0; diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java index 3bf18c520..5f4d66091 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java @@ -238,8 +238,8 @@ public class AndroidSpellCheckerService extends SpellCheckerService mScores = new int[mMaxLength]; } - synchronized public boolean oldAddWord(char[] word, int[] spaceIndices, int wordOffset, - int wordLength, int score, int dicTypeId /* unused */, int dataType) { + synchronized public boolean addWord(char[] word, int[] spaceIndices, int wordOffset, + int wordLength, int score) { final int positionIndex = Arrays.binarySearch(mScores, 0, mLength, score); // binarySearch returns the index if the element exists, and - - 1 // if it doesn't. See documentation for binarySearch. @@ -784,9 +784,8 @@ public class AndroidSpellCheckerService extends SpellCheckerService composer, prevWord, dictInfo.mProximityInfo); for (final SuggestedWordInfo suggestion : suggestions) { final String suggestionStr = suggestion.mWord.toString(); - suggestionsGatherer.oldAddWord(suggestionStr.toCharArray(), null, 0, - suggestionStr.length(), suggestion.mScore, 0 /* ignored */, - Dictionary.UNIGRAM); + suggestionsGatherer.addWord(suggestionStr.toCharArray(), null, 0, + suggestionStr.length(), suggestion.mScore); } isInDict = dictInfo.mDictionary.isValidWord(text); if (!isInDict && CAPITALIZE_NONE != capitalizeType) {