Pass an array to output suggestion types (A119a)
This needs the matching A119b change to not break the build. The array is passed, but not used yet. Bug: 6166228 Change-Id: Ia91d658461d989ee8c94e9b31bb06f4a36f4c5b6main
parent
2c5cf744e5
commit
6931df9c17
|
@ -55,6 +55,7 @@ public class BinaryDictionary extends Dictionary {
|
||||||
private final char[] mOutputChars = new char[MAX_WORD_LENGTH * MAX_RESULTS];
|
private final char[] mOutputChars = new char[MAX_WORD_LENGTH * MAX_RESULTS];
|
||||||
private final int[] mSpaceIndices = new int[MAX_SPACES];
|
private final int[] mSpaceIndices = new int[MAX_SPACES];
|
||||||
private final int[] mOutputScores = new int[MAX_RESULTS];
|
private final int[] mOutputScores = new int[MAX_RESULTS];
|
||||||
|
private final int[] mOutputTypes = new int[MAX_RESULTS];
|
||||||
|
|
||||||
private final boolean mUseFullEditDistance;
|
private final boolean mUseFullEditDistance;
|
||||||
|
|
||||||
|
@ -91,7 +92,7 @@ public class BinaryDictionary extends Dictionary {
|
||||||
int[] yCoordinates, int[] times, int[] pointerIds, int[] inputCodes, int codesSize,
|
int[] yCoordinates, int[] times, int[] pointerIds, int[] inputCodes, int codesSize,
|
||||||
int commitPoint, boolean isGesture,
|
int commitPoint, boolean isGesture,
|
||||||
int[] prevWordCodePointArray, boolean useFullEditDistance, char[] outputChars,
|
int[] prevWordCodePointArray, boolean useFullEditDistance, char[] outputChars,
|
||||||
int[] scores, int[] outputIndices);
|
int[] outputScores, int[] outputIndices, int[] outputTypes);
|
||||||
private static native float calcNormalizedScoreNative(
|
private static native float calcNormalizedScoreNative(
|
||||||
char[] before, int beforeLength, char[] after, int afterLength, int score);
|
char[] before, int beforeLength, char[] after, int afterLength, int score);
|
||||||
private static native int editDistanceNative(
|
private static native int editDistanceNative(
|
||||||
|
@ -128,8 +129,8 @@ public class BinaryDictionary extends Dictionary {
|
||||||
final int tmpCount = getSuggestionsNative(mNativeDict,
|
final int tmpCount = getSuggestionsNative(mNativeDict,
|
||||||
proximityInfo.getNativeProximityInfo(), ips.getXCoordinates(),
|
proximityInfo.getNativeProximityInfo(), ips.getXCoordinates(),
|
||||||
ips.getYCoordinates(), ips.getTimes(), ips.getPointerIds(),
|
ips.getYCoordinates(), ips.getTimes(), ips.getPointerIds(),
|
||||||
mInputCodes, codesSize, 0 /* unused */, isGesture, prevWordCodePointArray,
|
mInputCodes, codesSize, 0 /* commitPoint */, isGesture, prevWordCodePointArray,
|
||||||
mUseFullEditDistance, mOutputChars, mOutputScores, mSpaceIndices);
|
mUseFullEditDistance, mOutputChars, mOutputScores, mSpaceIndices, mOutputTypes);
|
||||||
final int count = Math.min(tmpCount, MAX_PREDICTIONS);
|
final int count = Math.min(tmpCount, MAX_PREDICTIONS);
|
||||||
|
|
||||||
final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<SuggestedWordInfo>();
|
final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<SuggestedWordInfo>();
|
||||||
|
|
|
@ -132,7 +132,7 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object,
|
||||||
jintArray timesArray, jintArray pointerIdArray, jintArray inputArray, jint arraySize,
|
jintArray timesArray, jintArray pointerIdArray, jintArray inputArray, jint arraySize,
|
||||||
jint commitPoint, jboolean isGesture,
|
jint commitPoint, jboolean isGesture,
|
||||||
jintArray prevWordForBigrams, jboolean useFullEditDistance, jcharArray outputArray,
|
jintArray prevWordForBigrams, jboolean useFullEditDistance, jcharArray outputArray,
|
||||||
jintArray frequencyArray, jintArray spaceIndexArray) {
|
jintArray frequencyArray, jintArray spaceIndexArray, jintArray outputTypesArray) {
|
||||||
Dictionary *dictionary = (Dictionary*) dict;
|
Dictionary *dictionary = (Dictionary*) dict;
|
||||||
if (!dictionary) return 0;
|
if (!dictionary) return 0;
|
||||||
ProximityInfo *pInfo = (ProximityInfo*)proximityInfo;
|
ProximityInfo *pInfo = (ProximityInfo*)proximityInfo;
|
||||||
|
@ -144,6 +144,7 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object,
|
||||||
int *inputCodes = env->GetIntArrayElements(inputArray, 0);
|
int *inputCodes = env->GetIntArrayElements(inputArray, 0);
|
||||||
jchar *outputChars = env->GetCharArrayElements(outputArray, 0);
|
jchar *outputChars = env->GetCharArrayElements(outputArray, 0);
|
||||||
int *spaceIndices = env->GetIntArrayElements(spaceIndexArray, 0);
|
int *spaceIndices = env->GetIntArrayElements(spaceIndexArray, 0);
|
||||||
|
int *outputTypes = env->GetIntArrayElements(outputTypesArray, 0);
|
||||||
jint *prevWordChars = prevWordForBigrams
|
jint *prevWordChars = prevWordForBigrams
|
||||||
? env->GetIntArrayElements(prevWordForBigrams, 0) : 0;
|
? env->GetIntArrayElements(prevWordForBigrams, 0) : 0;
|
||||||
jsize prevWordLength = prevWordChars ? env->GetArrayLength(prevWordForBigrams) : 0;
|
jsize prevWordLength = prevWordChars ? env->GetArrayLength(prevWordForBigrams) : 0;
|
||||||
|
@ -152,15 +153,17 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object,
|
||||||
if (isGesture || arraySize > 1) {
|
if (isGesture || arraySize > 1) {
|
||||||
count = dictionary->getSuggestions(pInfo, xCoordinates, yCoordinates, times, pointerIds,
|
count = dictionary->getSuggestions(pInfo, xCoordinates, yCoordinates, times, pointerIds,
|
||||||
inputCodes, arraySize, prevWordChars, prevWordLength, commitPoint, isGesture,
|
inputCodes, arraySize, prevWordChars, prevWordLength, commitPoint, isGesture,
|
||||||
useFullEditDistance, (unsigned short*) outputChars, frequencies, spaceIndices);
|
useFullEditDistance, (unsigned short*) outputChars, frequencies, spaceIndices,
|
||||||
|
outputTypes);
|
||||||
} else {
|
} else {
|
||||||
count = dictionary->getBigrams(prevWordChars, prevWordLength, inputCodes,
|
count = dictionary->getBigrams(prevWordChars, prevWordLength, inputCodes,
|
||||||
arraySize, (unsigned short*) outputChars, frequencies);
|
arraySize, (unsigned short*) outputChars, frequencies, outputTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prevWordChars) {
|
if (prevWordChars) {
|
||||||
env->ReleaseIntArrayElements(prevWordForBigrams, prevWordChars, JNI_ABORT);
|
env->ReleaseIntArrayElements(prevWordForBigrams, prevWordChars, JNI_ABORT);
|
||||||
}
|
}
|
||||||
|
env->ReleaseIntArrayElements(outputTypesArray, outputTypes, 0);
|
||||||
env->ReleaseIntArrayElements(spaceIndexArray, spaceIndices, 0);
|
env->ReleaseIntArrayElements(spaceIndexArray, spaceIndices, 0);
|
||||||
env->ReleaseCharArrayElements(outputArray, outputChars, 0);
|
env->ReleaseCharArrayElements(outputArray, outputChars, 0);
|
||||||
env->ReleaseIntArrayElements(inputArray, inputCodes, JNI_ABORT);
|
env->ReleaseIntArrayElements(inputArray, inputCodes, JNI_ABORT);
|
||||||
|
@ -250,7 +253,7 @@ void releaseDictBuf(void* dictBuf, const size_t length, int fd) {
|
||||||
static JNINativeMethod sMethods[] = {
|
static JNINativeMethod sMethods[] = {
|
||||||
{"openNative", "(Ljava/lang/String;JJIIIII)J", (void*)latinime_BinaryDictionary_open},
|
{"openNative", "(Ljava/lang/String;JJIIIII)J", (void*)latinime_BinaryDictionary_open},
|
||||||
{"closeNative", "(J)V", (void*)latinime_BinaryDictionary_close},
|
{"closeNative", "(J)V", (void*)latinime_BinaryDictionary_close},
|
||||||
{"getSuggestionsNative", "(JJ[I[I[I[I[IIIZ[IZ[C[I[I)I",
|
{"getSuggestionsNative", "(JJ[I[I[I[I[IIIZ[IZ[C[I[I[I)I",
|
||||||
(void*) latinime_BinaryDictionary_getSuggestions},
|
(void*) latinime_BinaryDictionary_getSuggestions},
|
||||||
{"getFrequencyNative", "(J[II)I", (void*)latinime_BinaryDictionary_getFrequency},
|
{"getFrequencyNative", "(J[II)I", (void*)latinime_BinaryDictionary_getFrequency},
|
||||||
{"isValidBigramNative", "(J[I[I)Z", (void*)latinime_BinaryDictionary_isValidBigram},
|
{"isValidBigramNative", "(J[I[I)Z", (void*)latinime_BinaryDictionary_isValidBigram},
|
||||||
|
|
|
@ -88,8 +88,7 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ
|
||||||
* codesSize: the size of the codes array.
|
* codesSize: the size of the codes array.
|
||||||
* bigramChars: an array for output, at the same format as outwords for getSuggestions.
|
* bigramChars: an array for output, at the same format as outwords for getSuggestions.
|
||||||
* bigramFreq: an array to output frequencies.
|
* bigramFreq: an array to output frequencies.
|
||||||
* maxWordLength: the maximum size of a word.
|
* outputTypes: an array to output types.
|
||||||
* maxBigrams: the maximum number of bigrams fitting in the bigramChars array.
|
|
||||||
* This method returns the number of bigrams this word has, for backward compatibility.
|
* This method returns the number of bigrams this word has, for backward compatibility.
|
||||||
* Note: this is not the number of bigrams output in the array, which is the number of
|
* Note: this is not the number of bigrams output in the array, which is the number of
|
||||||
* bigrams this word has WHOSE first letter also matches the letter the user typed.
|
* bigrams this word has WHOSE first letter also matches the letter the user typed.
|
||||||
|
@ -99,7 +98,7 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ
|
||||||
* reduce their scope to the ones that match the first letter.
|
* reduce their scope to the ones that match the first letter.
|
||||||
*/
|
*/
|
||||||
int BigramDictionary::getBigrams(const int32_t *prevWord, int prevWordLength, int *inputCodes,
|
int BigramDictionary::getBigrams(const int32_t *prevWord, int prevWordLength, int *inputCodes,
|
||||||
int codesSize, unsigned short *bigramChars, int *bigramFreq) const {
|
int codesSize, unsigned short *bigramChars, int *bigramFreq, int *outputTypes) const {
|
||||||
// TODO: remove unused arguments, and refrain from storing stuff in members of this class
|
// TODO: remove unused arguments, and refrain from storing stuff in members of this class
|
||||||
// TODO: have "in" arguments before "out" ones, and make out args explicit in the name
|
// TODO: have "in" arguments before "out" ones, and make out args explicit in the name
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ class BigramDictionary {
|
||||||
public:
|
public:
|
||||||
BigramDictionary(const unsigned char *dict, int maxWordLength, int maxPredictions);
|
BigramDictionary(const unsigned char *dict, int maxWordLength, int maxPredictions);
|
||||||
int getBigrams(const int32_t *word, int length, int *inputCodes, int codesSize,
|
int getBigrams(const int32_t *word, int length, int *inputCodes, int codesSize,
|
||||||
unsigned short *outWords, int *frequencies) const;
|
unsigned short *outWords, int *frequencies, int *outputTypes) const;
|
||||||
int getBigramListPositionForWord(const int32_t *prevWord, const int prevWordLength,
|
int getBigramListPositionForWord(const int32_t *prevWord, const int prevWordLength,
|
||||||
const bool forceLowerCaseSearch) const;
|
const bool forceLowerCaseSearch) const;
|
||||||
void fillBigramAddressToFrequencyMapAndFilter(const int32_t *prevWord, const int prevWordLength,
|
void fillBigramAddressToFrequencyMapAndFilter(const int32_t *prevWord, const int prevWordLength,
|
||||||
|
|
|
@ -38,13 +38,13 @@ class Dictionary {
|
||||||
int *times, int *pointerIds, int *codes, int codesSize, int *prevWordChars,
|
int *times, int *pointerIds, int *codes, int codesSize, int *prevWordChars,
|
||||||
int prevWordLength, int commitPoint, bool isGesture,
|
int prevWordLength, int commitPoint, bool isGesture,
|
||||||
bool useFullEditDistance, unsigned short *outWords,
|
bool useFullEditDistance, unsigned short *outWords,
|
||||||
int *frequencies, int *spaceIndices) {
|
int *frequencies, int *spaceIndices, int *outputTypes) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if (isGesture) {
|
if (isGesture) {
|
||||||
mGestureDecoder->setPrevWord(prevWordChars, prevWordLength);
|
mGestureDecoder->setPrevWord(prevWordChars, prevWordLength);
|
||||||
result = mGestureDecoder->getSuggestions(proximityInfo, xcoordinates, ycoordinates,
|
result = mGestureDecoder->getSuggestions(proximityInfo, xcoordinates, ycoordinates,
|
||||||
times, pointerIds, codes, codesSize, commitPoint,
|
times, pointerIds, codes, codesSize, commitPoint,
|
||||||
outWords, frequencies, spaceIndices);
|
outWords, frequencies, spaceIndices, outputTypes);
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
std::map<int, int> bigramMap;
|
std::map<int, int> bigramMap;
|
||||||
|
@ -53,15 +53,16 @@ class Dictionary {
|
||||||
prevWordLength, &bigramMap, bigramFilter);
|
prevWordLength, &bigramMap, bigramFilter);
|
||||||
result = mUnigramDictionary->getSuggestions(proximityInfo, xcoordinates,
|
result = mUnigramDictionary->getSuggestions(proximityInfo, xcoordinates,
|
||||||
ycoordinates, codes, codesSize, &bigramMap, bigramFilter,
|
ycoordinates, codes, codesSize, &bigramMap, bigramFilter,
|
||||||
useFullEditDistance, outWords, frequencies);
|
useFullEditDistance, outWords, frequencies, outputTypes);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int getBigrams(const int32_t *word, int length, int *codes, int codesSize,
|
int getBigrams(const int32_t *word, int length, int *codes, int codesSize,
|
||||||
unsigned short *outWords, int *frequencies) const {
|
unsigned short *outWords, int *frequencies, int *outputTypes) const {
|
||||||
if (length <= 0) return 0;
|
if (length <= 0) return 0;
|
||||||
return mBigramDictionary->getBigrams(word, length, codes, codesSize, outWords, frequencies);
|
return mBigramDictionary->getBigrams(word, length, codes, codesSize, outWords, frequencies,
|
||||||
|
outputTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getFrequency(const int32_t *word, int length) const;
|
int getFrequency(const int32_t *word, int length) const;
|
||||||
|
|
|
@ -39,13 +39,13 @@ class GestureDecoderWrapper : public IncrementalDecoderInterface {
|
||||||
|
|
||||||
int getSuggestions(ProximityInfo *pInfo, int *inputXs, int *inputYs, int *times,
|
int getSuggestions(ProximityInfo *pInfo, int *inputXs, int *inputYs, int *times,
|
||||||
int *pointerIds, int *codes, int inputSize, int commitPoint,
|
int *pointerIds, int *codes, int inputSize, int commitPoint,
|
||||||
unsigned short *outWords, int *frequencies, int *outputIndices) {
|
unsigned short *outWords, int *frequencies, int *outputIndices, int *outputTypes) {
|
||||||
if (!mIncrementalDecoderInterface) {
|
if (!mIncrementalDecoderInterface) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return mIncrementalDecoderInterface->getSuggestions(
|
return mIncrementalDecoderInterface->getSuggestions(
|
||||||
pInfo, inputXs, inputYs, times, pointerIds, codes, inputSize, commitPoint,
|
pInfo, inputXs, inputYs, times, pointerIds, codes, inputSize, commitPoint,
|
||||||
outWords, frequencies, outputIndices);
|
outWords, frequencies, outputIndices, outputTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
|
|
|
@ -30,7 +30,7 @@ class IncrementalDecoderInterface {
|
||||||
public:
|
public:
|
||||||
virtual int getSuggestions(ProximityInfo *pInfo, int *inputXs, int *inputYs, int *times,
|
virtual int getSuggestions(ProximityInfo *pInfo, int *inputXs, int *inputYs, int *times,
|
||||||
int *pointerIds, int *codes, int inputSize, int commitPoint,
|
int *pointerIds, int *codes, int inputSize, int commitPoint,
|
||||||
unsigned short *outWords, int *frequencies, int *outputIndices) = 0;
|
unsigned short *outWords, int *frequencies, int *outputIndices, int *outputTypes) = 0;
|
||||||
virtual void reset() = 0;
|
virtual void reset() = 0;
|
||||||
virtual void setDict(const UnigramDictionary *dict, const BigramDictionary *bigram,
|
virtual void setDict(const UnigramDictionary *dict, const BigramDictionary *bigram,
|
||||||
const uint8_t *dictRoot, int rootPos) = 0;
|
const uint8_t *dictRoot, int rootPos) = 0;
|
||||||
|
|
|
@ -173,7 +173,8 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo,
|
||||||
const int *xcoordinates,
|
const int *xcoordinates,
|
||||||
const int *ycoordinates, const int *codes, const int codesSize,
|
const int *ycoordinates, const int *codes, const int codesSize,
|
||||||
const std::map<int, int> *bigramMap, const uint8_t *bigramFilter,
|
const std::map<int, int> *bigramMap, const uint8_t *bigramFilter,
|
||||||
const bool useFullEditDistance, unsigned short *outWords, int *frequencies) const {
|
const bool useFullEditDistance, unsigned short *outWords, int *frequencies,
|
||||||
|
int *outputTypes) const {
|
||||||
|
|
||||||
WordsPriorityQueuePool queuePool(MAX_WORDS, SUB_QUEUE_MAX_WORDS, MAX_WORD_LENGTH);
|
WordsPriorityQueuePool queuePool(MAX_WORDS, SUB_QUEUE_MAX_WORDS, MAX_WORD_LENGTH);
|
||||||
queuePool.clearAll();
|
queuePool.clearAll();
|
||||||
|
|
|
@ -81,7 +81,7 @@ class UnigramDictionary {
|
||||||
ProximityInfo *proximityInfo, const int *xcoordinates, const int *ycoordinates,
|
ProximityInfo *proximityInfo, const int *xcoordinates, const int *ycoordinates,
|
||||||
const int *codes, const int codesSize, const std::map<int, int> *bigramMap,
|
const int *codes, const int codesSize, const std::map<int, int> *bigramMap,
|
||||||
const uint8_t *bigramFilter, const bool useFullEditDistance, unsigned short *outWords,
|
const uint8_t *bigramFilter, const bool useFullEditDistance, unsigned short *outWords,
|
||||||
int *frequencies) const;
|
int *frequencies, int *outputTypes) const;
|
||||||
virtual ~UnigramDictionary();
|
virtual ~UnigramDictionary();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue