diff options
author | 2012-07-10 22:48:38 -0700 | |
---|---|---|
committer | 2012-07-10 22:48:38 -0700 | |
commit | 0b329fd0d1f67b7f473e7ecfb5462ebb4ddd5fb8 (patch) | |
tree | 92609b6fc9737f31a28932b11bc82908be046992 /java/src | |
parent | a5acd68caacb223b34f3b86f141c91c21d93c604 (diff) | |
parent | ea98e026f1ad7732279aec6d06107f46ea0af93d (diff) | |
download | latinime-0b329fd0d1f67b7f473e7ecfb5462ebb4ddd5fb8.tar.gz latinime-0b329fd0d1f67b7f473e7ecfb5462ebb4ddd5fb8.tar.xz latinime-0b329fd0d1f67b7f473e7ecfb5462ebb4ddd5fb8.zip |
Merge "Pull up some more common code (A95)"
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/BinaryDictionary.java | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 252cdf1f9..c9402d96d 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -111,24 +111,26 @@ public class BinaryDictionary extends Dictionary { Arrays.fill(mInputCodes, WordComposer.NOT_A_CODE); Arrays.fill(mOutputChars, (char) 0); Arrays.fill(mOutputScores, 0); + // TODO: toLowerCase in the native code + final int[] prevWordCodePointArray = (null == prevWord) + ? null : StringUtils.toCodePointArray(prevWord.toString()); if (composer.size() <= 1) { - return TextUtils.isEmpty(prevWord) ? null : getBigramsInternal(composer, prevWord); + return TextUtils.isEmpty(prevWord) ? null : getBigramsInternal(composer, + prevWordCodePointArray); } else { - return getWordsInternal(composer, prevWord, proximityInfo); + return getWordsInternal(composer, prevWordCodePointArray, proximityInfo); } } // TODO: move to native code private ArrayList<SuggestedWordInfo> getBigramsInternal(final WordComposer codes, - final CharSequence previousWord) { - int[] codePoints = StringUtils.toCodePointArray(previousWord.toString()); - + final int[] previousWord) { int codesSize = codes.size(); if (codesSize > 0) { mInputCodes[0] = codes.getCodeAt(0); } - int count = getBigramsNative(mNativeDict, codePoints, codePoints.length, mInputCodes, + int count = getBigramsNative(mNativeDict, previousWord, previousWord.length, mInputCodes, codesSize, mOutputChars, mOutputScores, MAX_WORD_LENGTH, MAX_BIGRAMS); if (count > MAX_BIGRAMS) { count = MAX_BIGRAMS; @@ -154,9 +156,9 @@ public class BinaryDictionary extends Dictionary { // TODO: move to native code // proximityInfo and/or prevWordForBigrams may not be null. private ArrayList<SuggestedWordInfo> getWordsInternal(final WordComposer codes, - final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) { - final int count = getWordsInternalInternal(codes, prevWordForBigrams, proximityInfo, - mOutputChars, mOutputScores, mSpaceIndices); + final int[] prevWord, final ProximityInfo proximityInfo) { + final int count = getWordsInternalInternal(codes, prevWord, proximityInfo, mOutputChars, + mOutputScores, mSpaceIndices); final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<SuggestedWordInfo>(); for (int j = 0; j < count; ++j) { @@ -183,7 +185,7 @@ public class BinaryDictionary extends Dictionary { // proximityInfo may not be null. // TODO: remove this method by inlining it into getWordsInternal private int getWordsInternalInternal(final WordComposer codes, - final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo, + final int[] prevWord, final ProximityInfo proximityInfo, char[] outputChars, int[] scores, int[] spaceIndices) { final InputPointers ips = codes.getInputPointers(); final boolean isGesture = codes.isBatchMode(); @@ -199,13 +201,9 @@ public class BinaryDictionary extends Dictionary { } } - // TODO: toLowerCase in the native code - final int[] prevWordCodePointArray = (null == prevWordForBigrams) - ? null : StringUtils.toCodePointArray(prevWordForBigrams.toString()); - return getSuggestionsNative(mNativeDict, proximityInfo.getNativeProximityInfo(), ips.getXCoordinates(), ips.getYCoordinates(), ips.getTimes(), ips.getPointerIds(), - mInputCodes, codesSize, 0 /* unused */, isGesture, prevWordCodePointArray, + mInputCodes, codesSize, 0 /* unused */, isGesture, prevWord, mUseFullEditDistance, outputChars, scores, spaceIndices); } |