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
commit
e8ff9e107b
|
@ -162,7 +162,7 @@ public class BinaryDictionary extends Dictionary {
|
|||
}
|
||||
if (len > 0) {
|
||||
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) {
|
||||
callback.addWord(mOutputChars, start, len, mScores[j], mDicTypeId,
|
||||
DataType.UNIGRAM);
|
||||
Dictionary.UNIGRAM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,9 +33,8 @@ public abstract class Dictionary {
|
|||
*/
|
||||
protected static final int FULL_WORD_SCORE_MULTIPLIER = 2;
|
||||
|
||||
public static enum DataType {
|
||||
UNIGRAM, BIGRAM
|
||||
}
|
||||
public static final int UNIGRAM = 0;
|
||||
public static final int BIGRAM = 1;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* can exceed those limits
|
||||
* @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
|
||||
*/
|
||||
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 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.
|
||||
* @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,
|
||||
final ProximityInfo proximityInfo);
|
||||
|
|
|
@ -301,7 +301,7 @@ public class ExpandableDictionary extends Dictionary {
|
|||
finalFreq = computeSkippedWordFinalFreq(freq, snr, mInputLength);
|
||||
}
|
||||
if (!callback.addWord(word, 0, depth + 1, finalFreq, mDicTypeId,
|
||||
DataType.UNIGRAM)) {
|
||||
Dictionary.UNIGRAM)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ public class ExpandableDictionary extends Dictionary {
|
|||
snr * addedAttenuation, mInputLength);
|
||||
}
|
||||
callback.addWord(word, 0, depth + 1, finalFreq, mDicTypeId,
|
||||
DataType.UNIGRAM);
|
||||
Dictionary.UNIGRAM);
|
||||
}
|
||||
}
|
||||
if (children != null) {
|
||||
|
@ -506,7 +506,7 @@ public class ExpandableDictionary extends Dictionary {
|
|||
} while (node != null);
|
||||
|
||||
callback.addWord(mLookedUpString, index, MAX_WORD_LENGTH - index, freq, mDicTypeId,
|
||||
DataType.BIGRAM);
|
||||
Dictionary.BIGRAM);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ import android.content.SharedPreferences;
|
|||
import android.view.inputmethod.EditorInfo;
|
||||
|
||||
import com.android.inputmethod.keyboard.Keyboard;
|
||||
import com.android.inputmethod.latin.Dictionary.DataType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -75,7 +74,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
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) {
|
||||
|
|
|
@ -298,7 +298,7 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
if (typedWord != null) {
|
||||
// Treating USER_TYPED as UNIGRAM suggestion for logging now.
|
||||
LatinImeLogger.onAddSuggestedWord(typedWord, Suggest.DIC_USER_TYPED,
|
||||
Dictionary.DataType.UNIGRAM);
|
||||
Dictionary.UNIGRAM);
|
||||
}
|
||||
mConsideredWord = consideredWord;
|
||||
|
||||
|
@ -417,12 +417,12 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
|
||||
@Override
|
||||
public boolean addWord(final char[] word, final int offset, final int length, int score,
|
||||
final int dicTypeId, final Dictionary.DataType dataType) {
|
||||
Dictionary.DataType dataTypeForLog = dataType;
|
||||
final int dicTypeId, final int dataType) {
|
||||
int dataTypeForLog = dataType;
|
||||
final ArrayList<CharSequence> suggestions;
|
||||
final int[] sortedScores;
|
||||
final int prefMaxSuggestions;
|
||||
if(dataType == Dictionary.DataType.BIGRAM) {
|
||||
if (dataType == Dictionary.BIGRAM) {
|
||||
suggestions = mBigramSuggestions;
|
||||
sortedScores = mBigramScores;
|
||||
prefMaxSuggestions = PREF_MAX_BIGRAMS;
|
||||
|
@ -450,11 +450,11 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (dataType == Dictionary.DataType.UNIGRAM) {
|
||||
if (dataType == Dictionary.UNIGRAM) {
|
||||
// Check if the word was already added before (by bigram data)
|
||||
int bigramSuggestion = searchBigramSuggestion(word,offset,length);
|
||||
if(bigramSuggestion >= 0) {
|
||||
dataTypeForLog = Dictionary.DataType.BIGRAM;
|
||||
dataTypeForLog = Dictionary.BIGRAM;
|
||||
// turn freq from bigram into multiplier specified above
|
||||
double multiplier = (((double) mBigramScores[bigramSuggestion])
|
||||
/ MAXIMUM_BIGRAM_FREQUENCY)
|
||||
|
|
|
@ -31,7 +31,6 @@ import com.android.inputmethod.compat.SuggestionsInfoCompatUtils;
|
|||
import com.android.inputmethod.keyboard.ProximityInfo;
|
||||
import com.android.inputmethod.latin.BinaryDictionary;
|
||||
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.DictionaryCollection;
|
||||
import com.android.inputmethod.latin.DictionaryFactory;
|
||||
|
@ -237,7 +236,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService
|
|||
|
||||
@Override
|
||||
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);
|
||||
// binarySearch returns the index if the element exists, and -<insertion index> - 1
|
||||
// if it doesn't. See documentation for binarySearch.
|
||||
|
|
Loading…
Reference in New Issue