diff options
Diffstat (limited to 'native/jni/src')
-rw-r--r-- | native/jni/src/defines.h | 2 | ||||
-rw-r--r-- | native/jni/src/dictionary.cpp | 5 | ||||
-rw-r--r-- | native/jni/src/dictionary.h | 32 | ||||
-rw-r--r-- | native/jni/src/gesture/gesture_decoder_wrapper.cpp | 22 | ||||
-rw-r--r-- | native/jni/src/gesture/gesture_decoder_wrapper.h | 91 | ||||
-rw-r--r-- | native/jni/src/gesture/incremental_decoder_interface.h | 41 | ||||
-rw-r--r-- | native/jni/src/proximity_info.cpp | 22 | ||||
-rw-r--r-- | native/jni/src/proximity_info.h | 4 |
8 files changed, 9 insertions, 210 deletions
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 |