aboutsummaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
Diffstat (limited to 'native')
-rw-r--r--native/jni/Android.mk18
-rw-r--r--native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp25
-rw-r--r--native/jni/src/defines.h2
-rw-r--r--native/jni/src/dictionary.cpp5
-rw-r--r--native/jni/src/dictionary.h32
-rw-r--r--native/jni/src/gesture/gesture_decoder_wrapper.cpp22
-rw-r--r--native/jni/src/gesture/gesture_decoder_wrapper.h91
-rw-r--r--native/jni/src/gesture/incremental_decoder_interface.h41
-rw-r--r--native/jni/src/proximity_info.cpp22
-rw-r--r--native/jni/src/proximity_info.h4
10 files changed, 25 insertions, 237 deletions
diff --git a/native/jni/Android.mk b/native/jni/Android.mk
index d40063ed5..3bb7b58f1 100644
--- a/native/jni/Android.mk
+++ b/native/jni/Android.mk
@@ -17,16 +17,15 @@ LOCAL_PATH := $(call my-dir)
############ some local flags
# If you change any of those flags, you need to rebuild both libjni_latinime_static
# and the shared library.
-FLAG_DBG ?= false
+#FLAG_DBG := true
FLAG_DO_PROFILE ?= false
######################################
include $(CLEAR_VARS)
LATIN_IME_SRC_DIR := src
-LATIN_IME_SRC_FULLPATH_DIR := $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
-LOCAL_C_INCLUDES += $(LATIN_IME_SRC_FULLPATH_DIR) $(LATIN_IME_SRC_FULLPATH_DIR)/gesture
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
LOCAL_CFLAGS += -Werror -Wall
@@ -48,12 +47,11 @@ LATIN_IME_CORE_SRC_FILES := \
dictionary.cpp \
proximity_info.cpp \
proximity_info_state.cpp \
- unigram_dictionary.cpp \
- gesture/gesture_decoder_wrapper.cpp
+ unigram_dictionary.cpp
LOCAL_SRC_FILES := \
$(LATIN_IME_JNI_SRC_FILES) \
- $(addprefix $(LATIN_IME_SRC_DIR)/, $(LATIN_IME_CORE_SRC_FILES))
+ $(addprefix $(LATIN_IME_SRC_DIR)/,$(LATIN_IME_CORE_SRC_FILES))
ifeq ($(FLAG_DO_PROFILE), true)
$(warning Making profiling version of native library)
@@ -65,7 +63,7 @@ ifeq ($(FLAG_DBG), true)
endif # FLAG_DBG
endif # FLAG_DO_PROFILE
-LOCAL_MODULE := libjni_latinime_common_static
+LOCAL_MODULE := libjni_latinime_static
LOCAL_MODULE_TAGS := optional
ifdef HISTORICAL_NDK_VERSIONS_ROOT # In the platform build system
@@ -75,11 +73,12 @@ LOCAL_C_INCLUDES += external/stlport/stlport bionic
endif
include $(BUILD_STATIC_LIBRARY)
+
######################################
include $(CLEAR_VARS)
# All code in LOCAL_WHOLE_STATIC_LIBRARIES will be built into this shared library.
-LOCAL_WHOLE_STATIC_LIBRARIES := libjni_latinime_common_static
+LOCAL_WHOLE_STATIC_LIBRARIES := libjni_latinime_static
ifdef HISTORICAL_NDK_VERSIONS_ROOT # In the platform build system
LOCAL_SHARED_LIBRARIES := libstlport
@@ -109,6 +108,5 @@ include $(BUILD_SHARED_LIBRARY)
#################### Clean up the tmp vars
LATIN_IME_CORE_SRC_FILES :=
LATIN_IME_JNI_SRC_FILES :=
-LATIN_IME_GESTURE_IMPL_SRC_FILES :=
LATIN_IME_SRC_DIR :=
-LATIN_IME_SRC_FULLPATH_DIR :=
+TARGETING_UNBUNDLED_FROYO :=
diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
index bee0662ee..d10dc962e 100644
--- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
+++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
@@ -128,37 +128,28 @@ static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object, jlong dict,
jlong proximityInfo, jintArray xCoordinatesArray, jintArray yCoordinatesArray,
- jintArray timesArray, jintArray pointerIdArray, jintArray inputArray, jint arraySize,
- jint commitPoint, jboolean isGesture,
- jintArray prevWordForBigrams, jboolean useFullEditDistance, jcharArray outputArray,
- jintArray frequencyArray, jintArray spaceIndexArray) {
- Dictionary *dictionary = (Dictionary*) dict;
+ jintArray inputArray, jint arraySize, jintArray prevWordForBigrams,
+ jboolean useFullEditDistance, jcharArray outputArray, jintArray frequencyArray) {
+ Dictionary *dictionary = (Dictionary*)dict;
if (!dictionary) return 0;
ProximityInfo *pInfo = (ProximityInfo*)proximityInfo;
int *xCoordinates = env->GetIntArrayElements(xCoordinatesArray, 0);
int *yCoordinates = env->GetIntArrayElements(yCoordinatesArray, 0);
- int *times = env->GetIntArrayElements(timesArray, 0);
- int *pointerIds = env->GetIntArrayElements(pointerIdArray, 0);
int *frequencies = env->GetIntArrayElements(frequencyArray, 0);
int *inputCodes = env->GetIntArrayElements(inputArray, 0);
jchar *outputChars = env->GetCharArrayElements(outputArray, 0);
- int *spaceIndices = env->GetIntArrayElements(spaceIndexArray, 0);
jint *prevWordChars = prevWordForBigrams
? env->GetIntArrayElements(prevWordForBigrams, 0) : 0;
jsize prevWordLength = prevWordChars ? env->GetArrayLength(prevWordForBigrams) : 0;
- int count = dictionary->getSuggestions(pInfo, xCoordinates, yCoordinates, times, pointerIds,
- inputCodes, arraySize, prevWordChars, prevWordLength, commitPoint, isGesture,
- useFullEditDistance, (unsigned short*) outputChars,
- frequencies, spaceIndices);
+ int count = dictionary->getSuggestions(pInfo, xCoordinates, yCoordinates, inputCodes,
+ arraySize, prevWordChars, prevWordLength, useFullEditDistance,
+ (unsigned short*) outputChars, frequencies);
if (prevWordChars) {
env->ReleaseIntArrayElements(prevWordForBigrams, prevWordChars, JNI_ABORT);
}
- env->ReleaseIntArrayElements(spaceIndexArray, spaceIndices, 0);
env->ReleaseCharArrayElements(outputArray, outputChars, 0);
env->ReleaseIntArrayElements(inputArray, inputCodes, JNI_ABORT);
env->ReleaseIntArrayElements(frequencyArray, frequencies, 0);
- env->ReleaseIntArrayElements(pointerIdArray, pointerIds, 0);
- env->ReleaseIntArrayElements(timesArray, times, 0);
env->ReleaseIntArrayElements(yCoordinatesArray, yCoordinates, 0);
env->ReleaseIntArrayElements(xCoordinatesArray, xCoordinates, 0);
return count;
@@ -260,8 +251,8 @@ void releaseDictBuf(void* dictBuf, const size_t length, int fd) {
static JNINativeMethod sMethods[] = {
{"openNative", "(Ljava/lang/String;JJIIII)J", (void*)latinime_BinaryDictionary_open},
{"closeNative", "(J)V", (void*)latinime_BinaryDictionary_close},
- {"getSuggestionsNative", "(JJ[I[I[I[I[IIIZ[IZ[C[I[I)I",
- (void*) latinime_BinaryDictionary_getSuggestions},
+ {"getSuggestionsNative", "(JJ[I[I[II[IZ[C[I)I",
+ (void*)latinime_BinaryDictionary_getSuggestions},
{"getFrequencyNative", "(J[II)I", (void*)latinime_BinaryDictionary_getFrequency},
{"isValidBigramNative", "(J[I[I)Z", (void*)latinime_BinaryDictionary_isValidBigram},
{"getBigramsNative", "(J[II[II[C[III)I", (void*)latinime_BinaryDictionary_getBigrams},
diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h
index c7d3bf313..8bcadcbe9 100644
--- a/native/jni/src/defines.h
+++ b/native/jni/src/defines.h
@@ -255,8 +255,6 @@ static inline void prof_out(void) {
#define FIRST_WORD_INDEX 0
-#define MAX_SPACES_INTERNAL 16
-
// TODO: Reduce this constant if possible; check the maximum number of digraphs in the same
// word in the dictionary for languages with digraphs, like German and French
#define DEFAULT_MAX_DIGRAPH_SEARCH_DEPTH 5
diff --git a/native/jni/src/dictionary.cpp b/native/jni/src/dictionary.cpp
index 628a16933..83bb26731 100644
--- a/native/jni/src/dictionary.cpp
+++ b/native/jni/src/dictionary.cpp
@@ -22,7 +22,6 @@
#include "binary_format.h"
#include "defines.h"
#include "dictionary.h"
-#include "gesture_decoder_wrapper.h"
namespace latinime {
@@ -44,15 +43,11 @@ Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
mUnigramDictionary = new UnigramDictionary(mDict + headerSize, typedLetterMultiplier,
fullWordMultiplier, maxWordLength, maxWords, options);
mBigramDictionary = new BigramDictionary(mDict + headerSize, maxWordLength);
- mGestureDecoder = new GestureDecoderWrapper(maxWordLength, maxWords);
- mGestureDecoder->setDict(mUnigramDictionary, mBigramDictionary,
- mDict + headerSize /* dict root */, 0 /* root pos */);
}
Dictionary::~Dictionary() {
delete mUnigramDictionary;
delete mBigramDictionary;
- delete mGestureDecoder;
}
int Dictionary::getFrequency(const int32_t *word, int length) const {
diff --git a/native/jni/src/dictionary.h b/native/jni/src/dictionary.h
index 431f10337..fd69f79e3 100644
--- a/native/jni/src/dictionary.h
+++ b/native/jni/src/dictionary.h
@@ -22,7 +22,6 @@
#include "bigram_dictionary.h"
#include "char_utils.h"
#include "defines.h"
-#include "incremental_decoder_interface.h"
#include "proximity_info.h"
#include "unigram_dictionary.h"
#include "words_priority_queue_pool.h"
@@ -35,27 +34,15 @@ class Dictionary {
int fullWordMultiplier, int maxWordLength, int maxWords);
int getSuggestions(ProximityInfo *proximityInfo, int *xcoordinates, int *ycoordinates,
- 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 result = 0;
- if (isGesture) {
- mGestureDecoder->setPrevWord(prevWordChars, prevWordLength);
- result = mGestureDecoder->getSuggestions(proximityInfo, xcoordinates, ycoordinates,
- times, pointerIds, codes, codesSize, commitPoint,
- outWords, frequencies, spaceIndices);
- return result;
- } else {
- std::map<int, int> bigramMap;
- uint8_t bigramFilter[BIGRAM_FILTER_BYTE_SIZE];
- mBigramDictionary->fillBigramAddressToFrequencyMapAndFilter(prevWordChars,
- prevWordLength, &bigramMap, bigramFilter);
- result = mUnigramDictionary->getSuggestions(proximityInfo, xcoordinates,
- ycoordinates, codes, codesSize, &bigramMap, bigramFilter,
- useFullEditDistance, outWords, frequencies);
- return result;
- }
+ int *codes, int codesSize, const int32_t* prevWordChars, const int prevWordLength,
+ bool useFullEditDistance, unsigned short *outWords, int *frequencies) const {
+ std::map<int, int> bigramMap;
+ uint8_t bigramFilter[BIGRAM_FILTER_BYTE_SIZE];
+ mBigramDictionary->fillBigramAddressToFrequencyMapAndFilter(prevWordChars,
+ prevWordLength, &bigramMap, bigramFilter);
+ return mUnigramDictionary->getSuggestions(proximityInfo,
+ xcoordinates, ycoordinates, codes, codesSize, &bigramMap,
+ bigramFilter, useFullEditDistance, outWords, frequencies);
}
int getBigrams(const int32_t *word, int length, int *codes, int codesSize,
@@ -88,7 +75,6 @@ class Dictionary {
const UnigramDictionary *mUnigramDictionary;
const BigramDictionary *mBigramDictionary;
- IncrementalDecoderInterface *mGestureDecoder;
};
// public static utility methods
diff --git a/native/jni/src/gesture/gesture_decoder_wrapper.cpp b/native/jni/src/gesture/gesture_decoder_wrapper.cpp
deleted file mode 100644
index afbe0c5c3..000000000
--- a/native/jni/src/gesture/gesture_decoder_wrapper.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gesture_decoder_wrapper.h"
-
-namespace latinime {
- IncrementalDecoderInterface *
- (*GestureDecoderWrapper::sGestureDecoderFactoryMethod)(int, int) = 0;
-} // namespace latinime
diff --git a/native/jni/src/gesture/gesture_decoder_wrapper.h b/native/jni/src/gesture/gesture_decoder_wrapper.h
deleted file mode 100644
index 35982f03d..000000000
--- a/native/jni/src/gesture/gesture_decoder_wrapper.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef LATINIME_GESTURE_DECODER_WRAPPER_H
-#define LATINIME_GESTURE_DECODER_WRAPPER_H
-
-#include <stdint.h>
-#include "defines.h"
-#include "incremental_decoder_interface.h"
-
-namespace latinime {
-
-class UnigramDictionary;
-class BigramDictionary;
-class ProximityInfo;
-
-class GestureDecoderWrapper : public IncrementalDecoderInterface {
- public:
- GestureDecoderWrapper(const int maxWordLength, const int maxWords) {
- mIncrementalDecoderInterface = getGestureDecoderInstance(maxWordLength, maxWords);
- }
-
- virtual ~GestureDecoderWrapper() {
- delete mIncrementalDecoderInterface;
- }
-
- 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) {
- if (!mIncrementalDecoderInterface) {
- return 0;
- }
- return mIncrementalDecoderInterface->getSuggestions(
- pInfo, inputXs, inputYs, times, pointerIds, codes, inputSize, commitPoint,
- outWords, frequencies, outputIndices);
- }
-
- void reset() {
- if (!mIncrementalDecoderInterface) {
- return;
- }
- mIncrementalDecoderInterface->reset();
- }
-
- void setDict(const UnigramDictionary *dict, const BigramDictionary *bigram,
- const uint8_t *dictRoot, int rootPos) {
- if (!mIncrementalDecoderInterface) {
- return;
- }
- mIncrementalDecoderInterface->setDict(dict, bigram, dictRoot, rootPos);
- }
-
- void setPrevWord(const int32_t *prevWord, int prevWordLength) {
- if (!mIncrementalDecoderInterface) {
- return;
- }
- mIncrementalDecoderInterface->setPrevWord(prevWord, prevWordLength);
- }
-
- static void setGestureDecoderFactoryMethod(
- IncrementalDecoderInterface *(*factoryMethod)(int, int)) {
- sGestureDecoderFactoryMethod = factoryMethod;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(GestureDecoderWrapper);
- static IncrementalDecoderInterface *getGestureDecoderInstance(int maxWordLength, int maxWords) {
- if (sGestureDecoderFactoryMethod) {
- return sGestureDecoderFactoryMethod(maxWordLength, maxWords);
- }
- return 0;
- }
-
- static IncrementalDecoderInterface *(*sGestureDecoderFactoryMethod)(int, int);
- IncrementalDecoderInterface *mIncrementalDecoderInterface;
-};
-} // namespace latinime
-#endif // LATINIME_GESTURE_DECODER_WRAPPER_H
diff --git a/native/jni/src/gesture/incremental_decoder_interface.h b/native/jni/src/gesture/incremental_decoder_interface.h
deleted file mode 100644
index 957f1ebbe..000000000
--- a/native/jni/src/gesture/incremental_decoder_interface.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef LATINIME_INCREMENTAL_DECODER_INTERFACE_H
-#define LATINIME_INCREMENTAL_DECODER_INTERFACE_H
-
-#include <stdint.h>
-#include "defines.h"
-
-namespace latinime {
-
-class UnigramDictionary;
-class BigramDictionary;
-class ProximityInfo;
-
-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;
- virtual void reset() = 0;
- virtual void setDict(const UnigramDictionary *dict, const BigramDictionary *bigram,
- const uint8_t *dictRoot, int rootPos) = 0;
- virtual void setPrevWord(const int32_t *prevWord, int prevWordLength) = 0;
- virtual ~IncrementalDecoderInterface() { };
-};
-} // namespace latinime
-#endif // LATINIME_INCREMENTAL_DECODER_INTERFACE_H
diff --git a/native/jni/src/proximity_info.cpp b/native/jni/src/proximity_info.cpp
index a4a641160..2ba244a7c 100644
--- a/native/jni/src/proximity_info.cpp
+++ b/native/jni/src/proximity_info.cpp
@@ -15,7 +15,6 @@
*/
#include <assert.h>
-#include <math.h>
#include <stdio.h>
#include <string>
@@ -211,25 +210,4 @@ int ProximityInfo::getKeyIndex(const int c) const {
}
return mCodeToKeyIndex[baseLowerC];
}
-
-// TODO: [Staging] Optimize
-void ProximityInfo::getCenters(int *centerXs, int *centerYs, int *codeToKeyIndex,
- int *keyToCodeIndex, int *keyCount, int *keyWidth) const {
- *keyCount = KEY_COUNT;
- *keyWidth = sqrt((float)MOST_COMMON_KEY_WIDTH_SQUARE);
-
- for (int i = 0; i < KEY_COUNT; ++i) {
- const int code = mKeyCharCodes[i];
- const int lowerCode = toBaseLowerCase(code);
- centerXs[i] = mKeyXCoordinates[i] + mKeyWidths[i] / 2;
- centerYs[i] = mKeyYCoordinates[i] + mKeyHeights[i] / 2;
- codeToKeyIndex[code] = i;
- if (code != lowerCode && lowerCode >= 0 && lowerCode <= MAX_CHAR_CODE) {
- codeToKeyIndex[lowerCode] = i;
- keyToCodeIndex[i] = lowerCode;
- } else {
- keyToCodeIndex[i] = code;
- }
- }
-}
} // namespace latinime
diff --git a/native/jni/src/proximity_info.h b/native/jni/src/proximity_info.h
index d58935c6b..fec6555ea 100644
--- a/native/jni/src/proximity_info.h
+++ b/native/jni/src/proximity_info.h
@@ -98,10 +98,6 @@ class ProximityInfo {
return GRID_HEIGHT;
}
- // Returns the keyboard key-center information.
- void getCenters(int *centersX, int *centersY, int *codeToKeyIndex, int *keyToCodeIndex,
- int *keyCount, int *keyWidth) const;
-
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ProximityInfo);
// The max number of the keys in one keyboard layout