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: Ia91d658461d989ee8c94e9b31bb06f4a36f4c5b6
This commit is contained in:
Jean Chalard 2012-07-12 12:55:48 +09:00
parent 2c5cf744e5
commit 6931df9c17
9 changed files with 26 additions and 21 deletions

View file

@ -55,6 +55,7 @@ public class BinaryDictionary extends Dictionary {
private final char[] mOutputChars = new char[MAX_WORD_LENGTH * MAX_RESULTS];
private final int[] mSpaceIndices = new int[MAX_SPACES];
private final int[] mOutputScores = new int[MAX_RESULTS];
private final int[] mOutputTypes = new int[MAX_RESULTS];
private final boolean mUseFullEditDistance;
@ -91,7 +92,7 @@ public class BinaryDictionary extends Dictionary {
int[] yCoordinates, int[] times, int[] pointerIds, int[] inputCodes, int codesSize,
int commitPoint, boolean isGesture,
int[] prevWordCodePointArray, boolean useFullEditDistance, char[] outputChars,
int[] scores, int[] outputIndices);
int[] outputScores, int[] outputIndices, int[] outputTypes);
private static native float calcNormalizedScoreNative(
char[] before, int beforeLength, char[] after, int afterLength, int score);
private static native int editDistanceNative(
@ -128,8 +129,8 @@ public class BinaryDictionary extends Dictionary {
final int tmpCount = getSuggestionsNative(mNativeDict,
proximityInfo.getNativeProximityInfo(), ips.getXCoordinates(),
ips.getYCoordinates(), ips.getTimes(), ips.getPointerIds(),
mInputCodes, codesSize, 0 /* unused */, isGesture, prevWordCodePointArray,
mUseFullEditDistance, mOutputChars, mOutputScores, mSpaceIndices);
mInputCodes, codesSize, 0 /* commitPoint */, isGesture, prevWordCodePointArray,
mUseFullEditDistance, mOutputChars, mOutputScores, mSpaceIndices, mOutputTypes);
final int count = Math.min(tmpCount, MAX_PREDICTIONS);
final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<SuggestedWordInfo>();

View file

@ -132,7 +132,7 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object,
jintArray timesArray, jintArray pointerIdArray, jintArray inputArray, jint arraySize,
jint commitPoint, jboolean isGesture,
jintArray prevWordForBigrams, jboolean useFullEditDistance, jcharArray outputArray,
jintArray frequencyArray, jintArray spaceIndexArray) {
jintArray frequencyArray, jintArray spaceIndexArray, jintArray outputTypesArray) {
Dictionary *dictionary = (Dictionary*) dict;
if (!dictionary) return 0;
ProximityInfo *pInfo = (ProximityInfo*)proximityInfo;
@ -144,6 +144,7 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object,
int *inputCodes = env->GetIntArrayElements(inputArray, 0);
jchar *outputChars = env->GetCharArrayElements(outputArray, 0);
int *spaceIndices = env->GetIntArrayElements(spaceIndexArray, 0);
int *outputTypes = env->GetIntArrayElements(outputTypesArray, 0);
jint *prevWordChars = prevWordForBigrams
? env->GetIntArrayElements(prevWordForBigrams, 0) : 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) {
count = dictionary->getSuggestions(pInfo, xCoordinates, yCoordinates, times, pointerIds,
inputCodes, arraySize, prevWordChars, prevWordLength, commitPoint, isGesture,
useFullEditDistance, (unsigned short*) outputChars, frequencies, spaceIndices);
useFullEditDistance, (unsigned short*) outputChars, frequencies, spaceIndices,
outputTypes);
} else {
count = dictionary->getBigrams(prevWordChars, prevWordLength, inputCodes,
arraySize, (unsigned short*) outputChars, frequencies);
arraySize, (unsigned short*) outputChars, frequencies, outputTypes);
}
if (prevWordChars) {
env->ReleaseIntArrayElements(prevWordForBigrams, prevWordChars, JNI_ABORT);
}
env->ReleaseIntArrayElements(outputTypesArray, outputTypes, 0);
env->ReleaseIntArrayElements(spaceIndexArray, spaceIndices, 0);
env->ReleaseCharArrayElements(outputArray, outputChars, 0);
env->ReleaseIntArrayElements(inputArray, inputCodes, JNI_ABORT);
@ -250,7 +253,7 @@ void releaseDictBuf(void* dictBuf, const size_t length, int fd) {
static JNINativeMethod sMethods[] = {
{"openNative", "(Ljava/lang/String;JJIIIII)J", (void*)latinime_BinaryDictionary_open},
{"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},
{"getFrequencyNative", "(J[II)I", (void*)latinime_BinaryDictionary_getFrequency},
{"isValidBigramNative", "(J[I[I)Z", (void*)latinime_BinaryDictionary_isValidBigram},

View file

@ -88,8 +88,7 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ
* codesSize: the size of the codes array.
* bigramChars: an array for output, at the same format as outwords for getSuggestions.
* bigramFreq: an array to output frequencies.
* maxWordLength: the maximum size of a word.
* maxBigrams: the maximum number of bigrams fitting in the bigramChars array.
* outputTypes: an array to output types.
* 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
* 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.
*/
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: have "in" arguments before "out" ones, and make out args explicit in the name

View file

@ -29,7 +29,7 @@ class BigramDictionary {
public:
BigramDictionary(const unsigned char *dict, int maxWordLength, int maxPredictions);
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,
const bool forceLowerCaseSearch) const;
void fillBigramAddressToFrequencyMapAndFilter(const int32_t *prevWord, const int prevWordLength,

View file

@ -38,13 +38,13 @@ class Dictionary {
int *times, int *pointerIds, int *codes, int codesSize, int *prevWordChars,
int prevWordLength, int commitPoint, bool isGesture,
bool useFullEditDistance, unsigned short *outWords,
int *frequencies, int *spaceIndices) {
int *frequencies, int *spaceIndices, int *outputTypes) {
int result = 0;
if (isGesture) {
mGestureDecoder->setPrevWord(prevWordChars, prevWordLength);
result = mGestureDecoder->getSuggestions(proximityInfo, xcoordinates, ycoordinates,
times, pointerIds, codes, codesSize, commitPoint,
outWords, frequencies, spaceIndices);
outWords, frequencies, spaceIndices, outputTypes);
return result;
} else {
std::map<int, int> bigramMap;
@ -53,15 +53,16 @@ class Dictionary {
prevWordLength, &bigramMap, bigramFilter);
result = mUnigramDictionary->getSuggestions(proximityInfo, xcoordinates,
ycoordinates, codes, codesSize, &bigramMap, bigramFilter,
useFullEditDistance, outWords, frequencies);
useFullEditDistance, outWords, frequencies, outputTypes);
return result;
}
}
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;
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;

View file

@ -39,13 +39,13 @@ class GestureDecoderWrapper : public IncrementalDecoderInterface {
int getSuggestions(ProximityInfo *pInfo, int *inputXs, int *inputYs, int *times,
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) {
return 0;
}
return mIncrementalDecoderInterface->getSuggestions(
pInfo, inputXs, inputYs, times, pointerIds, codes, inputSize, commitPoint,
outWords, frequencies, outputIndices);
outWords, frequencies, outputIndices, outputTypes);
}
void reset() {

View file

@ -30,7 +30,7 @@ class IncrementalDecoderInterface {
public:
virtual int getSuggestions(ProximityInfo *pInfo, int *inputXs, int *inputYs, int *times,
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 setDict(const UnigramDictionary *dict, const BigramDictionary *bigram,
const uint8_t *dictRoot, int rootPos) = 0;

View file

@ -173,7 +173,8 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo,
const int *xcoordinates,
const int *ycoordinates, const int *codes, const int codesSize,
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);
queuePool.clearAll();

View file

@ -81,7 +81,7 @@ class UnigramDictionary {
ProximityInfo *proximityInfo, const int *xcoordinates, const int *ycoordinates,
const int *codes, const int codesSize, const std::map<int, int> *bigramMap,
const uint8_t *bigramFilter, const bool useFullEditDistance, unsigned short *outWords,
int *frequencies) const;
int *frequencies, int *outputTypes) const;
virtual ~UnigramDictionary();
private: