am 35314af0: Merge "Extend jni interface to input/output languageWeight."

* commit '35314af0d8566f539482ea7262cdec9f3f72c862':
  Extend jni interface to input/output languageWeight.
main
Keisuke Kuroyanagi 2014-04-02 16:23:55 +00:00 committed by Android Git Automerger
commit 176df4fa42
2 changed files with 15 additions and 4 deletions

View File

@ -97,6 +97,7 @@ public final class BinaryDictionary extends Dictionary {
private final int[] mOutputTypes = new int[MAX_RESULTS]; private final int[] mOutputTypes = new int[MAX_RESULTS];
// Only one result is ever used // Only one result is ever used
private final int[] mOutputAutoCommitFirstWordConfidence = new int[1]; private final int[] mOutputAutoCommitFirstWordConfidence = new int[1];
private final float[] mInputOutputLanguageWeight = new float[1];
private final NativeSuggestOptions mNativeSuggestOptions = new NativeSuggestOptions(); private final NativeSuggestOptions mNativeSuggestOptions = new NativeSuggestOptions();
@ -167,7 +168,7 @@ public final class BinaryDictionary extends Dictionary {
int[] pointerIds, int[] inputCodePoints, int inputSize, int[] suggestOptions, int[] pointerIds, int[] inputCodePoints, int inputSize, int[] suggestOptions,
int[] prevWordCodePointArray, int[] outputSuggestionCount, int[] outputCodePoints, int[] prevWordCodePointArray, int[] outputSuggestionCount, int[] outputCodePoints,
int[] outputScores, int[] outputIndices, int[] outputTypes, int[] outputScores, int[] outputIndices, int[] outputTypes,
int[] outputAutoCommitFirstWordConfidence); int[] outputAutoCommitFirstWordConfidence, float[] inOutLanguageWeight);
private static native void addUnigramWordNative(long dict, int[] word, int probability, private static native void addUnigramWordNative(long dict, int[] word, int probability,
int[] shortcutTarget, int shortcutProbability, boolean isNotAWord, int[] shortcutTarget, int shortcutProbability, boolean isNotAWord,
boolean isBlacklisted, int timestamp); boolean isBlacklisted, int timestamp);
@ -262,13 +263,22 @@ public final class BinaryDictionary extends Dictionary {
final int inputSize = isGesture ? ips.getPointerSize() : composerSize; final int inputSize = isGesture ? ips.getPointerSize() : composerSize;
mNativeSuggestOptions.setIsGesture(isGesture); mNativeSuggestOptions.setIsGesture(isGesture);
mNativeSuggestOptions.setAdditionalFeaturesOptions(additionalFeaturesOptions); mNativeSuggestOptions.setAdditionalFeaturesOptions(additionalFeaturesOptions);
if (inOutLanguageWeight != null) {
mInputOutputLanguageWeight[0] = inOutLanguageWeight[0];
} else {
mInputOutputLanguageWeight[0] = Dictionary.NOT_A_LANGUAGE_WEIGHT;
}
// proximityInfo and/or prevWordForBigrams may not be null. // proximityInfo and/or prevWordForBigrams may not be null.
getSuggestionsNative(mNativeDict, proximityInfo.getNativeProximityInfo(), getSuggestionsNative(mNativeDict, proximityInfo.getNativeProximityInfo(),
getTraverseSession(sessionId).getSession(), ips.getXCoordinates(), getTraverseSession(sessionId).getSession(), ips.getXCoordinates(),
ips.getYCoordinates(), ips.getTimes(), ips.getPointerIds(), mInputCodePoints, ips.getYCoordinates(), ips.getTimes(), ips.getPointerIds(), mInputCodePoints,
inputSize, mNativeSuggestOptions.getOptions(), inputSize, mNativeSuggestOptions.getOptions(),
prevWordCodePointArray, mOutputSuggestionCount, mOutputCodePoints, mOutputScores, prevWordCodePointArray, mOutputSuggestionCount, mOutputCodePoints, mOutputScores,
mSpaceIndices, mOutputTypes, mOutputAutoCommitFirstWordConfidence); mSpaceIndices, mOutputTypes, mOutputAutoCommitFirstWordConfidence,
mInputOutputLanguageWeight);
if (inOutLanguageWeight != null) {
inOutLanguageWeight[0] = mInputOutputLanguageWeight[0];
}
final int count = mOutputSuggestionCount[0]; final int count = mOutputSuggestionCount[0];
final ArrayList<SuggestedWordInfo> suggestions = CollectionUtils.newArrayList(); final ArrayList<SuggestedWordInfo> suggestions = CollectionUtils.newArrayList();
for (int j = 0; j < count; ++j) { for (int j = 0; j < count; ++j) {

View File

@ -146,7 +146,8 @@ static void latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jclass clazz,
jintArray inputCodePointsArray, jint inputSize, jintArray suggestOptions, jintArray inputCodePointsArray, jint inputSize, jintArray suggestOptions,
jintArray prevWordCodePointsForBigrams, jintArray outSuggestionCount, jintArray prevWordCodePointsForBigrams, jintArray outSuggestionCount,
jintArray outCodePointsArray, jintArray outScoresArray, jintArray outSpaceIndicesArray, jintArray outCodePointsArray, jintArray outScoresArray, jintArray outSpaceIndicesArray,
jintArray outTypesArray, jintArray outAutoCommitFirstWordConfidenceArray) { jintArray outTypesArray, jintArray outAutoCommitFirstWordConfidenceArray,
jfloatArray inOutLanguageWeight) {
Dictionary *dictionary = reinterpret_cast<Dictionary *>(dict); Dictionary *dictionary = reinterpret_cast<Dictionary *>(dict);
// Assign 0 to outSuggestionCount here in case of returning earlier in this method. // Assign 0 to outSuggestionCount here in case of returning earlier in this method.
int count = 0; int count = 0;
@ -489,7 +490,7 @@ static const JNINativeMethod sMethods[] = {
}, },
{ {
const_cast<char *>("getSuggestionsNative"), const_cast<char *>("getSuggestionsNative"),
const_cast<char *>("(JJJ[I[I[I[I[II[I[I[I[I[I[I[I[I)V"), const_cast<char *>("(JJJ[I[I[I[I[II[I[I[I[I[I[I[I[I[F)V"),
reinterpret_cast<void *>(latinime_BinaryDictionary_getSuggestions) reinterpret_cast<void *>(latinime_BinaryDictionary_getSuggestions)
}, },
{ {