am 5a38ff30: Merge "Convert an internal enum into an int of same underlying value."

* commit '5a38ff305f6ee95cecf2d337b7efda1eacff8140':
  Convert an internal enum into an int of same underlying value.
main
Jean Chalard 2012-01-25 21:15:19 -08:00 committed by Android Git Automerger
commit e8ff9e107b
6 changed files with 18 additions and 21 deletions

View File

@ -162,7 +162,7 @@ public class BinaryDictionary extends Dictionary {
} }
if (len > 0) { if (len > 0) {
callback.addWord(mOutputChars_bigrams, start, len, mBigramScores[j], callback.addWord(mOutputChars_bigrams, start, len, mBigramScores[j],
mDicTypeId, DataType.BIGRAM); mDicTypeId, Dictionary.BIGRAM);
} }
} }
} }
@ -182,7 +182,7 @@ public class BinaryDictionary extends Dictionary {
} }
if (len > 0) { if (len > 0) {
callback.addWord(mOutputChars, start, len, mScores[j], mDicTypeId, callback.addWord(mOutputChars, start, len, mScores[j], mDicTypeId,
DataType.UNIGRAM); Dictionary.UNIGRAM);
} }
} }
} }

View File

@ -33,9 +33,8 @@ public abstract class Dictionary {
*/ */
protected static final int FULL_WORD_SCORE_MULTIPLIER = 2; protected static final int FULL_WORD_SCORE_MULTIPLIER = 2;
public static enum DataType { public static final int UNIGRAM = 0;
UNIGRAM, BIGRAM public static final int BIGRAM = 1;
}
/** /**
* Interface to be implemented by classes requesting words to be fetched from the dictionary. * Interface to be implemented by classes requesting words to be fetched from the dictionary.
@ -51,11 +50,11 @@ public abstract class Dictionary {
* @param score the score of occurrence. This is normalized between 1 and 255, but * @param score the score of occurrence. This is normalized between 1 and 255, but
* can exceed those limits * can exceed those limits
* @param dicTypeId of the dictionary where word was from * @param dicTypeId of the dictionary where word was from
* @param dataType tells type of this data * @param dataType tells type of this data, either UNIGRAM or BIGRAM
* @return true if the word was added, false if no more words are required * @return true if the word was added, false if no more words are required
*/ */
boolean addWord(char[] word, int wordOffset, int wordLength, int score, int dicTypeId, boolean addWord(char[] word, int wordOffset, int wordLength, int score, int dicTypeId,
DataType dataType); int dataType);
} }
/** /**
@ -64,7 +63,7 @@ public abstract class Dictionary {
* @param composer the key sequence to match * @param composer the key sequence to match
* @param callback the callback object to send matched words to as possible candidates * @param callback the callback object to send matched words to as possible candidates
* @param proximityInfo the object for key proximity. May be ignored by some implementations. * @param proximityInfo the object for key proximity. May be ignored by some implementations.
* @see WordCallback#addWord(char[], int, int, int, int, DataType) * @see WordCallback#addWord(char[], int, int, int, int, int)
*/ */
abstract public void getWords(final WordComposer composer, final WordCallback callback, abstract public void getWords(final WordComposer composer, final WordCallback callback,
final ProximityInfo proximityInfo); final ProximityInfo proximityInfo);

View File

@ -301,7 +301,7 @@ public class ExpandableDictionary extends Dictionary {
finalFreq = computeSkippedWordFinalFreq(freq, snr, mInputLength); finalFreq = computeSkippedWordFinalFreq(freq, snr, mInputLength);
} }
if (!callback.addWord(word, 0, depth + 1, finalFreq, mDicTypeId, if (!callback.addWord(word, 0, depth + 1, finalFreq, mDicTypeId,
DataType.UNIGRAM)) { Dictionary.UNIGRAM)) {
return; return;
} }
} }
@ -342,7 +342,7 @@ public class ExpandableDictionary extends Dictionary {
snr * addedAttenuation, mInputLength); snr * addedAttenuation, mInputLength);
} }
callback.addWord(word, 0, depth + 1, finalFreq, mDicTypeId, callback.addWord(word, 0, depth + 1, finalFreq, mDicTypeId,
DataType.UNIGRAM); Dictionary.UNIGRAM);
} }
} }
if (children != null) { if (children != null) {
@ -506,7 +506,7 @@ public class ExpandableDictionary extends Dictionary {
} while (node != null); } while (node != null);
callback.addWord(mLookedUpString, index, MAX_WORD_LENGTH - index, freq, mDicTypeId, callback.addWord(mLookedUpString, index, MAX_WORD_LENGTH - index, freq, mDicTypeId,
DataType.BIGRAM); Dictionary.BIGRAM);
} }
} }

View File

@ -21,7 +21,6 @@ import android.content.SharedPreferences;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.Dictionary.DataType;
import java.util.List; import java.util.List;
@ -75,7 +74,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
public static void onStartSuggestion(CharSequence previousWords) { public static void onStartSuggestion(CharSequence previousWords) {
} }
public static void onAddSuggestedWord(String word, int typeId, DataType dataType) { public static void onAddSuggestedWord(String word, int typeId, int dataType) {
} }
public static void onSetKeyboard(Keyboard kb) { public static void onSetKeyboard(Keyboard kb) {

View File

@ -298,7 +298,7 @@ public class Suggest implements Dictionary.WordCallback {
if (typedWord != null) { if (typedWord != null) {
// Treating USER_TYPED as UNIGRAM suggestion for logging now. // Treating USER_TYPED as UNIGRAM suggestion for logging now.
LatinImeLogger.onAddSuggestedWord(typedWord, Suggest.DIC_USER_TYPED, LatinImeLogger.onAddSuggestedWord(typedWord, Suggest.DIC_USER_TYPED,
Dictionary.DataType.UNIGRAM); Dictionary.UNIGRAM);
} }
mConsideredWord = consideredWord; mConsideredWord = consideredWord;
@ -417,12 +417,12 @@ public class Suggest implements Dictionary.WordCallback {
@Override @Override
public boolean addWord(final char[] word, final int offset, final int length, int score, public boolean addWord(final char[] word, final int offset, final int length, int score,
final int dicTypeId, final Dictionary.DataType dataType) { final int dicTypeId, final int dataType) {
Dictionary.DataType dataTypeForLog = dataType; int dataTypeForLog = dataType;
final ArrayList<CharSequence> suggestions; final ArrayList<CharSequence> suggestions;
final int[] sortedScores; final int[] sortedScores;
final int prefMaxSuggestions; final int prefMaxSuggestions;
if(dataType == Dictionary.DataType.BIGRAM) { if (dataType == Dictionary.BIGRAM) {
suggestions = mBigramSuggestions; suggestions = mBigramSuggestions;
sortedScores = mBigramScores; sortedScores = mBigramScores;
prefMaxSuggestions = PREF_MAX_BIGRAMS; prefMaxSuggestions = PREF_MAX_BIGRAMS;
@ -450,11 +450,11 @@ public class Suggest implements Dictionary.WordCallback {
} }
} }
} else { } else {
if (dataType == Dictionary.DataType.UNIGRAM) { if (dataType == Dictionary.UNIGRAM) {
// Check if the word was already added before (by bigram data) // Check if the word was already added before (by bigram data)
int bigramSuggestion = searchBigramSuggestion(word,offset,length); int bigramSuggestion = searchBigramSuggestion(word,offset,length);
if(bigramSuggestion >= 0) { if(bigramSuggestion >= 0) {
dataTypeForLog = Dictionary.DataType.BIGRAM; dataTypeForLog = Dictionary.BIGRAM;
// turn freq from bigram into multiplier specified above // turn freq from bigram into multiplier specified above
double multiplier = (((double) mBigramScores[bigramSuggestion]) double multiplier = (((double) mBigramScores[bigramSuggestion])
/ MAXIMUM_BIGRAM_FREQUENCY) / MAXIMUM_BIGRAM_FREQUENCY)

View File

@ -31,7 +31,6 @@ import com.android.inputmethod.compat.SuggestionsInfoCompatUtils;
import com.android.inputmethod.keyboard.ProximityInfo; import com.android.inputmethod.keyboard.ProximityInfo;
import com.android.inputmethod.latin.BinaryDictionary; import com.android.inputmethod.latin.BinaryDictionary;
import com.android.inputmethod.latin.Dictionary; import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.Dictionary.DataType;
import com.android.inputmethod.latin.Dictionary.WordCallback; import com.android.inputmethod.latin.Dictionary.WordCallback;
import com.android.inputmethod.latin.DictionaryCollection; import com.android.inputmethod.latin.DictionaryCollection;
import com.android.inputmethod.latin.DictionaryFactory; import com.android.inputmethod.latin.DictionaryFactory;
@ -237,7 +236,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService
@Override @Override
synchronized public boolean addWord(char[] word, int wordOffset, int wordLength, int score, synchronized public boolean addWord(char[] word, int wordOffset, int wordLength, int score,
int dicTypeId, DataType dataType) { int dicTypeId, int dataType) {
final int positionIndex = ArraysCompatUtils.binarySearch(mScores, 0, mLength, score); final int positionIndex = ArraysCompatUtils.binarySearch(mScores, 0, mLength, score);
// binarySearch returns the index if the element exists, and -<insertion index> - 1 // binarySearch returns the index if the element exists, and -<insertion index> - 1
// if it doesn't. See documentation for binarySearch. // if it doesn't. See documentation for binarySearch.