From 1de95ceada64e7fd27ca4ee43243930b5d9c1df7 Mon Sep 17 00:00:00 2001 From: Keisuke Kuroyanagi Date: Thu, 3 Apr 2014 01:01:51 +0900 Subject: [PATCH] Extend jni interface to input/output languageWeight. Bug: 8187060 Change-Id: Ic55d328b87f258f4d65fff207233789a53b2b0ff --- .../inputmethod/latin/BinaryDictionary.java | 14 ++++++++++++-- ..._android_inputmethod_latin_BinaryDictionary.cpp | 5 +++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 32f905628..43a44221d 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -97,6 +97,7 @@ public final class BinaryDictionary extends Dictionary { private final int[] mOutputTypes = new int[MAX_RESULTS]; // Only one result is ever used private final int[] mOutputAutoCommitFirstWordConfidence = new int[1]; + private final float[] mInputOutputLanguageWeight = new float[1]; 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[] prevWordCodePointArray, int[] outputSuggestionCount, int[] outputCodePoints, int[] outputScores, int[] outputIndices, int[] outputTypes, - int[] outputAutoCommitFirstWordConfidence); + int[] outputAutoCommitFirstWordConfidence, float[] inOutLanguageWeight); private static native void addUnigramWordNative(long dict, int[] word, int probability, int[] shortcutTarget, int shortcutProbability, boolean isNotAWord, boolean isBlacklisted, int timestamp); @@ -262,13 +263,22 @@ public final class BinaryDictionary extends Dictionary { final int inputSize = isGesture ? ips.getPointerSize() : composerSize; mNativeSuggestOptions.setIsGesture(isGesture); 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. getSuggestionsNative(mNativeDict, proximityInfo.getNativeProximityInfo(), getTraverseSession(sessionId).getSession(), ips.getXCoordinates(), ips.getYCoordinates(), ips.getTimes(), ips.getPointerIds(), mInputCodePoints, inputSize, mNativeSuggestOptions.getOptions(), prevWordCodePointArray, mOutputSuggestionCount, mOutputCodePoints, mOutputScores, - mSpaceIndices, mOutputTypes, mOutputAutoCommitFirstWordConfidence); + mSpaceIndices, mOutputTypes, mOutputAutoCommitFirstWordConfidence, + mInputOutputLanguageWeight); + if (inOutLanguageWeight != null) { + inOutLanguageWeight[0] = mInputOutputLanguageWeight[0]; + } final int count = mOutputSuggestionCount[0]; final ArrayList suggestions = CollectionUtils.newArrayList(); for (int j = 0; j < count; ++j) { diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp index 154ea9800..a52833b81 100644 --- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp +++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp @@ -146,7 +146,8 @@ static void latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jclass clazz, jintArray inputCodePointsArray, jint inputSize, jintArray suggestOptions, jintArray prevWordCodePointsForBigrams, jintArray outSuggestionCount, jintArray outCodePointsArray, jintArray outScoresArray, jintArray outSpaceIndicesArray, - jintArray outTypesArray, jintArray outAutoCommitFirstWordConfidenceArray) { + jintArray outTypesArray, jintArray outAutoCommitFirstWordConfidenceArray, + jfloatArray inOutLanguageWeight) { Dictionary *dictionary = reinterpret_cast(dict); // Assign 0 to outSuggestionCount here in case of returning earlier in this method. int count = 0; @@ -489,7 +490,7 @@ static const JNINativeMethod sMethods[] = { }, { const_cast("getSuggestionsNative"), - const_cast("(JJJ[I[I[I[I[II[I[I[I[I[I[I[I[I)V"), + const_cast("(JJJ[I[I[I[I[II[I[I[I[I[I[I[I[I[F)V"), reinterpret_cast(latinime_BinaryDictionary_getSuggestions) }, {