aboutsummaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
Diffstat (limited to 'native')
-rw-r--r--native/jni/Android.mk6
-rw-r--r--native/jni/src/char_utils.h1
-rw-r--r--native/jni/src/defines.h68
-rw-r--r--native/jni/src/dictionary.cpp8
-rw-r--r--native/jni/src/dictionary.h4
-rw-r--r--native/jni/src/gesture/gesture_decoder_wrapper.h66
-rw-r--r--native/jni/src/gesture/incremental_decoder_wrapper.h67
-rw-r--r--native/jni/src/proximity_info_state.cpp4
-rw-r--r--native/jni/src/proximity_info_state.h2
-rw-r--r--native/jni/src/suggest/gesture_suggest.cpp (renamed from native/jni/src/gesture/gesture_decoder_wrapper.cpp)9
-rw-r--r--native/jni/src/suggest/gesture_suggest.h63
-rw-r--r--native/jni/src/suggest/suggest_interface.h (renamed from native/jni/src/gesture/incremental_decoder_interface.h)16
-rw-r--r--native/jni/src/suggest/typing_suggest.cpp (renamed from native/jni/src/gesture/incremental_decoder_wrapper.cpp)9
-rw-r--r--native/jni/src/suggest/typing_suggest.h63
14 files changed, 182 insertions, 204 deletions
diff --git a/native/jni/Android.mk b/native/jni/Android.mk
index c616be56e..a8a88712a 100644
--- a/native/jni/Android.mk
+++ b/native/jni/Android.mk
@@ -26,7 +26,7 @@ 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 += $(LATIN_IME_SRC_FULLPATH_DIR) $(LATIN_IME_SRC_FULLPATH_DIR)/suggest
LOCAL_CFLAGS += -Werror -Wall -Wextra -Weffc++ -Wformat=2 -Wcast-qual -Wcast-align \
-Wwrite-strings -Wfloat-equal -Wpointer-arith -Winit-self -Wredundant-decls -Wno-system-headers
@@ -57,8 +57,8 @@ LATIN_IME_CORE_SRC_FILES := \
proximity_info_state.cpp \
unigram_dictionary.cpp \
words_priority_queue.cpp \
- gesture/gesture_decoder_wrapper.cpp \
- gesture/incremental_decoder_wrapper.cpp
+ suggest/gesture_suggest.cpp \
+ suggest/typing_suggest.cpp
LOCAL_SRC_FILES := \
$(LATIN_IME_JNI_SRC_FILES) \
diff --git a/native/jni/src/char_utils.h b/native/jni/src/char_utils.h
index c632b79b8..60da203b9 100644
--- a/native/jni/src/char_utils.h
+++ b/native/jni/src/char_utils.h
@@ -72,6 +72,5 @@ inline static bool isSkippableCodePoint(const int codePoint) {
// TODO: Do not hardcode here
return codePoint == KEYCODE_SINGLE_QUOTE || codePoint == KEYCODE_HYPHEN_MINUS;
}
-
} // namespace latinime
#endif // LATINIME_CHAR_UTILS_H
diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h
index 90f714bec..7b127a2af 100644
--- a/native/jni/src/defines.h
+++ b/native/jni/src/defines.h
@@ -23,6 +23,9 @@
#define AK_FORCE_INLINE inline
#endif // __GNUC__
+// This must be greater than or equal to MAX_WORD_LENGTH defined in BinaryDictionary.java
+#define MAX_WORD_LENGTH_INTERNAL 48
+
#if defined(FLAG_DO_PROFILE) || defined(FLAG_DBG)
#include <android/log.h>
#ifndef LOG_TAG
@@ -37,20 +40,33 @@
#define INTS_TO_CHARS(input, length, output) do { \
intArrayToCharArray(input, length, output); } while (0)
+// TODO: Support full UTF-8 conversion
+AK_FORCE_INLINE static int intArrayToCharArray(const int *source, const int sourceSize,
+ char *dest) {
+ int si = 0;
+ int di = 0;
+ while (si < sourceSize && di < MAX_WORD_LENGTH_INTERNAL - 1 && 0 != source[si]) {
+ const int codePoint = source[si++];
+ if (codePoint < 0x7F) {
+ dest[di++] = codePoint;
+ } else if (codePoint < 0x7FF) {
+ dest[di++] = 0xC0 + (codePoint >> 6);
+ dest[di++] = 0x80 + (codePoint & 0x3F);
+ } else if (codePoint < 0xFFFF) {
+ dest[di++] = 0xE0 + (codePoint >> 12);
+ dest[di++] = 0x80 + ((codePoint & 0xFC0) >> 6);
+ dest[di++] = 0x80 + (codePoint & 0x3F);
+ }
+ }
+ dest[di] = 0;
+ return di;
+}
+
static inline void dumpWordInfo(const int *word, const int length, const int rank,
const int frequency) {
static char charBuf[50];
- int i = 0;
- for (; i < length; ++i) {
- const int c = word[i];
- if (c == 0) {
- break;
- }
- // static_cast only for debugging
- charBuf[i] = static_cast<char>(c);
- }
- charBuf[i] = 0;
- if (i > 1) {
+ const int N = intArrayToCharArray(word, length, charBuf);
+ if (N > 1) {
AKLOGI("%2d [ %s ] (%d)", rank, charBuf, frequency);
}
}
@@ -66,34 +82,12 @@ static inline void dumpResult(const int *outWords, const int *frequencies, const
static AK_FORCE_INLINE void dumpWord(const int *word, const int length) {
static char charBuf[50];
- int i = 0;
- for (; i < length; ++i) {
- const int c = word[i];
- if (c == 0) {
- break;
- }
- // static_cast only for debugging
- charBuf[i] = static_cast<char>(c);
- }
- charBuf[i] = 0;
- if (i > 1) {
+ const int N = intArrayToCharArray(word, length, charBuf);
+ if (N > 1) {
AKLOGI("[ %s ]", charBuf);
}
}
-static inline void intArrayToCharArray(const int *input, const int length, char *output) {
- int i = 0;
- for (; i < length; ++i) {
- const int c = input[i];
- if (c == 0) {
- break;
- }
- // static_cast only for debugging
- output[i] = static_cast<char>(c);
- }
- output[i] = 0;
-}
-
#ifndef __ANDROID__
#include <cassert>
#include <execinfo.h>
@@ -320,10 +314,6 @@ static inline void prof_out(void) {
#define MAX_FREQ 255
#define MAX_BIGRAM_FREQ 15
-// This must be greater than or equal to MAX_WORD_LENGTH defined in BinaryDictionary.java
-// This is only used for the size of array. Not to be used in c functions.
-#define MAX_WORD_LENGTH_INTERNAL 48
-
// This must be the same as ProximityInfo#MAX_PROXIMITY_CHARS_SIZE, currently it's 16.
#define MAX_PROXIMITY_CHARS_SIZE_INTERNAL 16
diff --git a/native/jni/src/dictionary.cpp b/native/jni/src/dictionary.cpp
index 8210aa0ff..167b36f11 100644
--- a/native/jni/src/dictionary.cpp
+++ b/native/jni/src/dictionary.cpp
@@ -23,7 +23,7 @@
#include "defines.h"
#include "dictionary.h"
#include "dic_traverse_wrapper.h"
-#include "gesture_decoder_wrapper.h"
+#include "gesture_suggest.h"
#include "unigram_dictionary.h"
namespace latinime {
@@ -36,7 +36,7 @@ Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
mUnigramDictionary(new UnigramDictionary(mOffsetDict, maxWordLength, maxWords,
BinaryFormat::getFlags(mDict))),
mBigramDictionary(new BigramDictionary(mOffsetDict, maxWordLength, maxPredictions)),
- mGestureDecoder(new GestureDecoderWrapper(maxWordLength, maxWords)) {
+ mGestureSuggest(new GestureSuggest(maxWordLength, maxWords)) {
if (DEBUG_DICT) {
if (MAX_WORD_LENGTH_INTERNAL < maxWordLength) {
AKLOGI("Max word length (%d) is greater than %d",
@@ -49,7 +49,7 @@ Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
Dictionary::~Dictionary() {
delete mUnigramDictionary;
delete mBigramDictionary;
- delete mGestureDecoder;
+ delete mGestureSuggest;
}
int Dictionary::getSuggestions(ProximityInfo *proximityInfo, void *traverseSession,
@@ -61,7 +61,7 @@ int Dictionary::getSuggestions(ProximityInfo *proximityInfo, void *traverseSessi
if (isGesture) {
DicTraverseWrapper::initDicTraverseSession(
traverseSession, this, prevWordChars, prevWordLength);
- result = mGestureDecoder->getSuggestions(proximityInfo, traverseSession,
+ result = mGestureSuggest->getSuggestions(proximityInfo, traverseSession,
xcoordinates, ycoordinates, times, pointerIds, codes, codesSize, commitPoint,
outWords, frequencies, spaceIndices, outputTypes);
if (DEBUG_DICT) {
diff --git a/native/jni/src/dictionary.h b/native/jni/src/dictionary.h
index e9660002e..26edc4f2f 100644
--- a/native/jni/src/dictionary.h
+++ b/native/jni/src/dictionary.h
@@ -24,8 +24,8 @@
namespace latinime {
class BigramDictionary;
-class IncrementalDecoderInterface;
class ProximityInfo;
+class SuggestInterface;
class UnigramDictionary;
class Dictionary {
@@ -83,7 +83,7 @@ class Dictionary {
const UnigramDictionary *mUnigramDictionary;
const BigramDictionary *mBigramDictionary;
- IncrementalDecoderInterface *mGestureDecoder;
+ SuggestInterface *mGestureSuggest;
};
// public static utility methods
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 b96814907..000000000
--- a/native/jni/src/gesture/gesture_decoder_wrapper.h
+++ /dev/null
@@ -1,66 +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 "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();
-
- int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs,
- int *times, int *pointerIds, int *codes, int inputSize, int commitPoint, int *outWords,
- int *frequencies, int *outputIndices, int *outputTypes) const {
- if (!mIncrementalDecoderInterface) {
- return 0;
- }
- return mIncrementalDecoderInterface->getSuggestions(pInfo, traverseSession, inputXs,
- inputYs, times, pointerIds, codes, inputSize, commitPoint, outWords, frequencies,
- outputIndices, outputTypes);
- }
-
- static void setGestureDecoderFactoryMethod(
- IncrementalDecoderInterface *(*factoryMethod)(int, int)) {
- sGestureDecoderFactoryMethod = factoryMethod;
- }
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(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_wrapper.h b/native/jni/src/gesture/incremental_decoder_wrapper.h
deleted file mode 100644
index c15b439fa..000000000
--- a/native/jni/src/gesture/incremental_decoder_wrapper.h
+++ /dev/null
@@ -1,67 +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_WRAPPER_H
-#define LATINIME_INCREMENTAL_DECODER_WRAPPER_H
-
-#include "defines.h"
-#include "incremental_decoder_interface.h"
-
-namespace latinime {
-
-class UnigramDictionary;
-class BigramDictionary;
-class ProximityInfo;
-
-class IncrementalDecoderWrapper : public IncrementalDecoderInterface {
- public:
- IncrementalDecoderWrapper(const int maxWordLength, const int maxWords)
- : mIncrementalDecoderInterface(getIncrementalDecoderInstance(maxWordLength, maxWords)) {
- }
-
- virtual ~IncrementalDecoderWrapper();
-
- int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs,
- int *times, int *pointerIds, int *codes, int inputSize, int commitPoint, int *outWords,
- int *frequencies, int *outputIndices, int *outputTypes) const {
- if (!mIncrementalDecoderInterface) {
- return 0;
- }
- return mIncrementalDecoderInterface->getSuggestions(pInfo, traverseSession, inputXs,
- inputYs, times, pointerIds, codes, inputSize, commitPoint, outWords, frequencies,
- outputIndices, outputTypes);
- }
-
- static void setIncrementalDecoderFactoryMethod(
- IncrementalDecoderInterface *(*factoryMethod)(int, int)) {
- sIncrementalDecoderFactoryMethod = factoryMethod;
- }
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalDecoderWrapper);
- static IncrementalDecoderInterface *getIncrementalDecoderInstance(int maxWordLength,
- int maxWords) {
- if (sIncrementalDecoderFactoryMethod) {
- return sIncrementalDecoderFactoryMethod(maxWordLength, maxWords);
- }
- return 0;
- }
-
- static IncrementalDecoderInterface *(*sIncrementalDecoderFactoryMethod)(int, int);
- IncrementalDecoderInterface *mIncrementalDecoderInterface;
-};
-} // namespace latinime
-#endif // LATINIME_INCREMENTAL_DECODER_WRAPPER_H
diff --git a/native/jni/src/proximity_info_state.cpp b/native/jni/src/proximity_info_state.cpp
index 549ac3544..bd2149ad1 100644
--- a/native/jni/src/proximity_info_state.cpp
+++ b/native/jni/src/proximity_info_state.cpp
@@ -1168,9 +1168,9 @@ bool ProximityInfoState::suppressCharProbabilities(const int index0, const int i
return true;
}
-// Get a word that is detected by tracing the most probable char sequence into codePointBuf and
+// Get a word that is detected by tracing the most probable string into codePointBuf and
// returns probability of generating the word.
-float ProximityInfoState::getMostProbableCharSequence(int *const codePointBuf) const {
+float ProximityInfoState::getMostProbableString(int *const codePointBuf) const {
static const float DEMOTION_LOG_PROBABILITY = 0.3f;
int index = 0;
float sumLogProbability = 0.0f;
diff --git a/native/jni/src/proximity_info_state.h b/native/jni/src/proximity_info_state.h
index b1ad3731e..10e74a0a3 100644
--- a/native/jni/src/proximity_info_state.h
+++ b/native/jni/src/proximity_info_state.h
@@ -196,7 +196,7 @@ class ProximityInfoState {
// Returns angle of three points. x, y, and z are indices.
float getPointsAngle(const int index0, const int index1, const int index2) const;
- float getMostProbableCharSequence(int *const codePointBuf) const;
+ float getMostProbableString(int *const codePointBuf) const;
float getProbability(const int index, const int charCode) const;
diff --git a/native/jni/src/gesture/gesture_decoder_wrapper.cpp b/native/jni/src/suggest/gesture_suggest.cpp
index 20ad4a58c..2a604b8ab 100644
--- a/native/jni/src/gesture/gesture_decoder_wrapper.cpp
+++ b/native/jni/src/suggest/gesture_suggest.cpp
@@ -14,13 +14,12 @@
* limitations under the License.
*/
-#include "gesture_decoder_wrapper.h"
+#include "gesture_suggest.h"
namespace latinime {
- IncrementalDecoderInterface *
- (*GestureDecoderWrapper::sGestureDecoderFactoryMethod)(int, int) = 0;
+ SuggestInterface *(*GestureSuggest::sGestureSuggestFactoryMethod)(int, int) = 0;
- GestureDecoderWrapper::~GestureDecoderWrapper() {
- delete mIncrementalDecoderInterface;
+ GestureSuggest::~GestureSuggest() {
+ delete mSuggestInterface;
}
} // namespace latinime
diff --git a/native/jni/src/suggest/gesture_suggest.h b/native/jni/src/suggest/gesture_suggest.h
new file mode 100644
index 000000000..e4af03fb8
--- /dev/null
+++ b/native/jni/src/suggest/gesture_suggest.h
@@ -0,0 +1,63 @@
+/*
+ * 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_SUGGEST_H
+#define LATINIME_GESTURE_SUGGEST_H
+
+#include "defines.h"
+#include "suggest_interface.h"
+
+namespace latinime {
+
+class ProximityInfo;
+
+class GestureSuggest : public SuggestInterface {
+ public:
+ GestureSuggest(const int maxWordLength, const int maxWords)
+ : mSuggestInterface(getGestureSuggestInstance(maxWordLength, maxWords)) {
+ }
+
+ virtual ~GestureSuggest();
+
+ int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs,
+ int *times, int *pointerIds, int *codes, int inputSize, int commitPoint, int *outWords,
+ int *frequencies, int *outputIndices, int *outputTypes) const {
+ if (!mSuggestInterface) {
+ return 0;
+ }
+ return mSuggestInterface->getSuggestions(pInfo, traverseSession, inputXs, inputYs, times,
+ pointerIds, codes, inputSize, commitPoint, outWords, frequencies, outputIndices,
+ outputTypes);
+ }
+
+ static void setGestureSuggestFactoryMethod(SuggestInterface *(*factoryMethod)(int, int)) {
+ sGestureSuggestFactoryMethod = factoryMethod;
+ }
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(GestureSuggest);
+ static SuggestInterface *getGestureSuggestInstance(int maxWordLength, int maxWords) {
+ if (!sGestureSuggestFactoryMethod) {
+ return 0;
+ }
+ return sGestureSuggestFactoryMethod(maxWordLength, maxWords);
+ }
+
+ static SuggestInterface *(*sGestureSuggestFactoryMethod)(int, int);
+ SuggestInterface *mSuggestInterface;
+};
+} // namespace latinime
+#endif // LATINIME_GESTURE_SUGGEST_H
diff --git a/native/jni/src/gesture/incremental_decoder_interface.h b/native/jni/src/suggest/suggest_interface.h
index ff85adc61..de58e7918 100644
--- a/native/jni/src/gesture/incremental_decoder_interface.h
+++ b/native/jni/src/suggest/suggest_interface.h
@@ -14,26 +14,24 @@
* limitations under the License.
*/
-#ifndef LATINIME_INCREMENTAL_DECODER_INTERFACE_H
-#define LATINIME_INCREMENTAL_DECODER_INTERFACE_H
+#ifndef LATINIME_SUGGEST_INTERFACE_H
+#define LATINIME_SUGGEST_INTERFACE_H
#include "defines.h"
namespace latinime {
-class UnigramDictionary;
-class BigramDictionary;
class ProximityInfo;
-class IncrementalDecoderInterface {
+class SuggestInterface {
public:
virtual int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs,
int *inputYs, int *times, int *pointerIds, int *codes, int inputSize, int commitPoint,
int *outWords, int *frequencies, int *outputIndices, int *outputTypes) const = 0;
- IncrementalDecoderInterface() { };
- virtual ~IncrementalDecoderInterface() { };
+ SuggestInterface() {};
+ virtual ~SuggestInterface() {};
private:
- DISALLOW_COPY_AND_ASSIGN(IncrementalDecoderInterface);
+ DISALLOW_COPY_AND_ASSIGN(SuggestInterface);
};
} // namespace latinime
-#endif // LATINIME_INCREMENTAL_DECODER_INTERFACE_H
+#endif // LATINIME_SUGGEST_INTERFACE_H
diff --git a/native/jni/src/gesture/incremental_decoder_wrapper.cpp b/native/jni/src/suggest/typing_suggest.cpp
index f6e45623a..40d4a98b0 100644
--- a/native/jni/src/gesture/incremental_decoder_wrapper.cpp
+++ b/native/jni/src/suggest/typing_suggest.cpp
@@ -14,13 +14,12 @@
* limitations under the License.
*/
-#include "incremental_decoder_wrapper.h"
+#include "typing_suggest.h"
namespace latinime {
- IncrementalDecoderInterface *
- (*IncrementalDecoderWrapper::sIncrementalDecoderFactoryMethod)(int, int) = 0;
+ SuggestInterface *(*TypingSuggest::sTypingSuggestFactoryMethod)(int, int) = 0;
- IncrementalDecoderWrapper::~IncrementalDecoderWrapper() {
- delete mIncrementalDecoderInterface;
+ TypingSuggest::~TypingSuggest() {
+ delete mSuggestInterface;
}
} // namespace latinime
diff --git a/native/jni/src/suggest/typing_suggest.h b/native/jni/src/suggest/typing_suggest.h
new file mode 100644
index 000000000..9de4158f5
--- /dev/null
+++ b/native/jni/src/suggest/typing_suggest.h
@@ -0,0 +1,63 @@
+/*
+ * 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_TYPING_SUGGEST_H
+#define LATINIME_TYPING_SUGGEST_H
+
+#include "defines.h"
+#include "suggest_interface.h"
+
+namespace latinime {
+
+class ProximityInfo;
+
+class TypingSuggest : public SuggestInterface {
+ public:
+ TypingSuggest(const int maxWordLength, const int maxWords)
+ : mSuggestInterface(getTypingSuggestInstance(maxWordLength, maxWords)) {
+ }
+
+ virtual ~TypingSuggest();
+
+ int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs,
+ int *times, int *pointerIds, int *codes, int inputSize, int commitPoint, int *outWords,
+ int *frequencies, int *outputIndices, int *outputTypes) const {
+ if (!mSuggestInterface) {
+ return 0;
+ }
+ return mSuggestInterface->getSuggestions(pInfo, traverseSession, inputXs, inputYs, times,
+ pointerIds, codes, inputSize, commitPoint, outWords, frequencies, outputIndices,
+ outputTypes);
+ }
+
+ static void setTypingSuggestFactoryMethod(SuggestInterface *(*factoryMethod)(int, int)) {
+ sTypingSuggestFactoryMethod = factoryMethod;
+ }
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(TypingSuggest);
+ static SuggestInterface *getTypingSuggestInstance(int maxWordLength, int maxWords) {
+ if (!sTypingSuggestFactoryMethod) {
+ return 0;
+ }
+ return sTypingSuggestFactoryMethod(maxWordLength, maxWords);
+ }
+
+ static SuggestInterface *(*sTypingSuggestFactoryMethod)(int, int);
+ SuggestInterface *mSuggestInterface;
+};
+} // namespace latinime
+#endif // LATINIME_TYPING_SUGGEST_H