aboutsummaryrefslogtreecommitdiffstats
path: root/native/src/dictionary.cpp
diff options
context:
space:
mode:
authorKen Wakasa <kwakasa@google.com>2011-01-07 15:01:51 +0900
committerKen Wakasa <kwakasa@google.com>2011-01-07 19:51:45 +0900
commite90b333017c68e888a5e3d351f07ea29036457d0 (patch)
treedd51657376f1c571df581b7016be891d09246be5 /native/src/dictionary.cpp
parentf16028b92e15c0fdf3fdc364d7888cf024723b00 (diff)
downloadlatinime-e90b333017c68e888a5e3d351f07ea29036457d0.tar.gz
latinime-e90b333017c68e888a5e3d351f07ea29036457d0.tar.xz
latinime-e90b333017c68e888a5e3d351f07ea29036457d0.zip
Load main dic in native
Follow up to Id57dce51 bug: 3219819 Change-Id: I00e11ef21d0252ffa88c12dffb9c55b0f2e19a66
Diffstat (limited to 'native/src/dictionary.cpp')
-rw-r--r--native/src/dictionary.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/native/src/dictionary.cpp b/native/src/dictionary.cpp
index 8d3290945..fe3375706 100644
--- a/native/src/dictionary.cpp
+++ b/native/src/dictionary.cpp
@@ -23,21 +23,23 @@
namespace latinime {
-Dictionary::Dictionary(void *dict, int typedLetterMultiplier, int fullWordMultiplier,
+Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
+ int typedLetterMultiplier, int fullWordMultiplier,
int maxWordLength, int maxWords, int maxAlternatives)
- : DICT((unsigned char*) dict),
+ : mDict((unsigned char*) dict), mDictSize(dictSize),
+ mMmapFd(mmapFd), mDictBufAdjust(dictBufAdjust),
// Checks whether it has the latest dictionary or the old dictionary
IS_LATEST_DICT_VERSION((((unsigned char*) dict)[0] & 0xFF) >= DICTIONARY_VERSION_MIN) {
if (DEBUG_DICT) {
if (MAX_WORD_LENGTH_INTERNAL < maxWordLength) {
LOGI("Max word length (%d) is greater than %d",
maxWordLength, MAX_WORD_LENGTH_INTERNAL);
- LOGI("IN NATIVE SUGGEST Version: %d \n", (DICT[0] & 0xFF));
+ LOGI("IN NATIVE SUGGEST Version: %d", (mDict[0] & 0xFF));
}
}
- mUnigramDictionary = new UnigramDictionary(DICT, typedLetterMultiplier, fullWordMultiplier,
+ mUnigramDictionary = new UnigramDictionary(mDict, typedLetterMultiplier, fullWordMultiplier,
maxWordLength, maxWords, maxAlternatives, IS_LATEST_DICT_VERSION);
- mBigramDictionary = new BigramDictionary(DICT, maxWordLength, maxAlternatives,
+ mBigramDictionary = new BigramDictionary(mDict, maxWordLength, maxAlternatives,
IS_LATEST_DICT_VERSION, hasBigram(), this);
}
@@ -47,7 +49,7 @@ Dictionary::~Dictionary() {
}
bool Dictionary::hasBigram() {
- return ((DICT[1] & 0xFF) == 1);
+ return ((mDict[1] & 0xFF) == 1);
}
// TODO: use uint16_t instead of unsigned short
@@ -64,12 +66,12 @@ int Dictionary::isValidWordRec(int pos, unsigned short *word, int offset, int le
// returns address of bigram data of that word
// return -99 if not found
- int count = Dictionary::getCount(DICT, &pos);
+ int count = Dictionary::getCount(mDict, &pos);
unsigned short currentChar = (unsigned short) word[offset];
for (int j = 0; j < count; j++) {
- unsigned short c = Dictionary::getChar(DICT, &pos);
- int terminal = Dictionary::getTerminal(DICT, &pos);
- int childPos = Dictionary::getAddress(DICT, &pos);
+ unsigned short c = Dictionary::getChar(mDict, &pos);
+ int terminal = Dictionary::getTerminal(mDict, &pos);
+ int childPos = Dictionary::getAddress(mDict, &pos);
if (c == currentChar) {
if (offset == length - 1) {
if (terminal) {
@@ -85,7 +87,7 @@ int Dictionary::isValidWordRec(int pos, unsigned short *word, int offset, int le
}
}
if (terminal) {
- Dictionary::getFreq(DICT, IS_LATEST_DICT_VERSION, &pos);
+ Dictionary::getFreq(mDict, IS_LATEST_DICT_VERSION, &pos);
}
// There could be two instances of each alphabet - upper and lower case. So continue
// looking ...