Change native functions' interface for gesture

Change-Id: I106a858f0be7452dd89f425805a6f72aa88c3f65
main
Satoshi Kataoka 2012-06-27 14:52:40 +09:00
parent a3f5f51ec4
commit efb63246c2
7 changed files with 34 additions and 3 deletions

View File

@ -26,6 +26,8 @@ include $(CLEAR_VARS)
LATIN_IME_SRC_DIR := src
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)/gesture
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)/gesture/impl
LOCAL_CFLAGS += -Werror -Wall

View File

@ -44,7 +44,8 @@ Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
fullWordMultiplier, maxWordLength, maxWords, options);
mBigramDictionary = new BigramDictionary(mDict + headerSize, maxWordLength);
mGestureDecoder = new GestureDecoder(maxWordLength, maxWords);
mGestureDecoder->setDict(mUnigramDictionary, mBigramDictionary);
mGestureDecoder->setDict(mUnigramDictionary, mBigramDictionary,
mDict + headerSize /* dict root */, 0 /* root pos */);
}
Dictionary::~Dictionary() {

View File

@ -28,7 +28,8 @@ class IncrementalDecoderImpl : IncrementalDecoderInterface {
public:
IncrementalDecoderImpl(int maxWordLength, int maxWords) { };
void setDict(const UnigramDictionary *dict, const BigramDictionary *bigram) { };
void setDict(const UnigramDictionary *dict, const BigramDictionary *bigram,
const uint8_t *dictRoot, int rootPos) { };
void setPrevWord(const int32_t *prevWord, int prevWordLength) { };
void reset() { };

View File

@ -31,7 +31,8 @@ class IncrementalDecoderInterface {
int *pointerIds, int *codes, int inputSize, int commitPoint, bool isMainDict,
unsigned short *outWords, int *frequencies, int *outputIndices) = 0;
virtual void reset() = 0;
virtual void setDict(const UnigramDictionary *dict, const BigramDictionary *bigram) = 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() { };
};

View File

@ -15,6 +15,7 @@
*/
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <string>
@ -210,4 +211,25 @@ 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

View File

@ -98,6 +98,10 @@ 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