Cosmetic fixes and style fixes

Change-Id: I69c42ff945cdf0d5205c6ca61d6861a0479492dc
main
Ken Wakasa 2012-07-25 17:51:43 +09:00
parent 0657b9698a
commit 0bbb917d12
33 changed files with 365 additions and 401 deletions

View File

@ -1,19 +1,19 @@
/* /*
** *
** Copyright 2011, The Android Open Source Project * Copyright 2011, The Android Open Source Project
** *
** Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
** You may obtain a copy of the License at * You may obtain a copy of the License at
** *
** http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
** *
** Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
** limitations under the License. * limitations under the License.
*/ */
#define LOG_TAG "LatinIME: jni: ProximityInfo" #define LOG_TAG "LatinIME: jni: ProximityInfo"
@ -85,5 +85,4 @@ int register_ProximityInfo(JNIEnv *env) {
return registerNativeMethods(env, kClassPathName, sKeyboardMethods, return registerNativeMethods(env, kClassPathName, sKeyboardMethods,
sizeof(sKeyboardMethods) / sizeof(sKeyboardMethods[0])); sizeof(sKeyboardMethods) / sizeof(sKeyboardMethods[0]));
} }
} // namespace latinime } // namespace latinime

View File

@ -1,19 +1,19 @@
/* /*
** *
** Copyright 2011, The Android Open Source Project * Copyright 2011, The Android Open Source Project
** *
** Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
** You may obtain a copy of the License at * You may obtain a copy of the License at
** *
** http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
** *
** Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
** limitations under the License. * limitations under the License.
*/ */
#ifndef _COM_ANDROID_INPUTMETHOD_KEYBOARD_PROXIMITYINFO_H #ifndef _COM_ANDROID_INPUTMETHOD_KEYBOARD_PROXIMITYINFO_H
#define _COM_ANDROID_INPUTMETHOD_KEYBOARD_PROXIMITYINFO_H #define _COM_ANDROID_INPUTMETHOD_KEYBOARD_PROXIMITYINFO_H
@ -24,6 +24,5 @@ namespace latinime {
int register_ProximityInfo(JNIEnv *env); int register_ProximityInfo(JNIEnv *env);
} } // namespace latinime
#endif // _COM_ANDROID_INPUTMETHOD_KEYBOARD_PROXIMITYINFO_H #endif // _COM_ANDROID_INPUTMETHOD_KEYBOARD_PROXIMITYINFO_H

View File

@ -1,19 +1,19 @@
/* /*
** *
** Copyright 2009, The Android Open Source Project * Copyright 2009, The Android Open Source Project
** *
** Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
** You may obtain a copy of the License at * You may obtain a copy of the License at
** *
** http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
** *
** Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
** limitations under the License. * limitations under the License.
*/ */
#define LOG_TAG "LatinIME: jni: BinaryDictionary" #define LOG_TAG "LatinIME: jni: BinaryDictionary"
@ -42,7 +42,7 @@
namespace latinime { namespace latinime {
void releaseDictBuf(void* dictBuf, const size_t length, int fd); void releaseDictBuf(void *dictBuf, const size_t length, int fd);
static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object, static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
jstring sourceDir, jlong dictOffset, jlong dictSize, jstring sourceDir, jlong dictOffset, jlong dictSize,
@ -235,7 +235,7 @@ static void latinime_BinaryDictionary_close(JNIEnv *env, jobject object, jlong d
delete dictionary; delete dictionary;
} }
void releaseDictBuf(void* dictBuf, const size_t length, int fd) { void releaseDictBuf(void *dictBuf, const size_t length, int fd) {
#ifdef USE_MMAP_FOR_DICTIONARY #ifdef USE_MMAP_FOR_DICTIONARY
int ret = munmap(dictBuf, length); int ret = munmap(dictBuf, length);
if (ret != 0) { if (ret != 0) {
@ -263,9 +263,8 @@ static JNINativeMethod sMethods[] = {
}; };
int register_BinaryDictionary(JNIEnv *env) { int register_BinaryDictionary(JNIEnv *env) {
const char* const kClassPathName = "com/android/inputmethod/latin/BinaryDictionary"; const char *const kClassPathName = "com/android/inputmethod/latin/BinaryDictionary";
return registerNativeMethods(env, kClassPathName, sMethods, return registerNativeMethods(env, kClassPathName, sMethods,
sizeof(sMethods) / sizeof(sMethods[0])); sizeof(sMethods) / sizeof(sMethods[0]));
} }
} // namespace latinime } // namespace latinime

View File

@ -1,19 +1,19 @@
/* /*
** *
** Copyright 2011, The Android Open Source Project * Copyright 2011, The Android Open Source Project
** *
** Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
** You may obtain a copy of the License at * You may obtain a copy of the License at
** *
** http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
** *
** Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
** limitations under the License. * limitations under the License.
*/ */
#ifndef _COM_ANDROID_INPUTMETHOD_LATIN_BINARYDICTIONARY_H #ifndef _COM_ANDROID_INPUTMETHOD_LATIN_BINARYDICTIONARY_H
#define _COM_ANDROID_INPUTMETHOD_LATIN_BINARYDICTIONARY_H #define _COM_ANDROID_INPUTMETHOD_LATIN_BINARYDICTIONARY_H
@ -24,6 +24,5 @@ namespace latinime {
int register_BinaryDictionary(JNIEnv *env); int register_BinaryDictionary(JNIEnv *env);
} } // namespace latinime
#endif // _COM_ANDROID_INPUTMETHOD_LATIN_BINARYDICTIONARY_H #endif // _COM_ANDROID_INPUTMETHOD_LATIN_BINARYDICTIONARY_H

View File

@ -1,19 +1,19 @@
/* /*
** *
** Copyright 2012, The Android Open Source Project * Copyright 2012, The Android Open Source Project
** *
** Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
** You may obtain a copy of the License at * You may obtain a copy of the License at
** *
** http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
** *
** Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
** limitations under the License. * limitations under the License.
*/ */
#include "com_android_inputmethod_latin_NativeUtils.h" #include "com_android_inputmethod_latin_NativeUtils.h"
#include "jni.h" #include "jni.h"
@ -32,9 +32,8 @@ static JNINativeMethod sMethods[] = {
}; };
int register_NativeUtils(JNIEnv *env) { int register_NativeUtils(JNIEnv *env) {
const char* const kClassPathName = "com/android/inputmethod/latin/NativeUtils"; const char *const kClassPathName = "com/android/inputmethod/latin/NativeUtils";
return registerNativeMethods(env, kClassPathName, sMethods, return registerNativeMethods(env, kClassPathName, sMethods,
sizeof(sMethods) / sizeof(sMethods[0])); sizeof(sMethods) / sizeof(sMethods[0]));
} }
} // namespace latinime } // namespace latinime

View File

@ -1,19 +1,19 @@
/* /*
** *
** Copyright 2012, The Android Open Source Project * Copyright 2012, The Android Open Source Project
** *
** Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
** You may obtain a copy of the License at * You may obtain a copy of the License at
** *
** http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
** *
** Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
** limitations under the License. * limitations under the License.
*/ */
#ifndef _COM_ANDROID_INPUTMETHOD_LATIN_NATIVEUTILS_H #ifndef _COM_ANDROID_INPUTMETHOD_LATIN_NATIVEUTILS_H
#define _COM_ANDROID_INPUTMETHOD_LATIN_NATIVEUTILS_H #define _COM_ANDROID_INPUTMETHOD_LATIN_NATIVEUTILS_H
@ -24,6 +24,5 @@ namespace latinime {
int register_NativeUtils(JNIEnv *env); int register_NativeUtils(JNIEnv *env);
} } // namespace latinime
#endif // _COM_ANDROID_INPUTMETHOD_LATIN_NATIVEUTILS_H #endif // _COM_ANDROID_INPUTMETHOD_LATIN_NATIVEUTILS_H

View File

@ -1,19 +1,19 @@
/* /*
** *
** Copyright 2011, The Android Open Source Project * Copyright 2011, The Android Open Source Project
** *
** Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
** You may obtain a copy of the License at * You may obtain a copy of the License at
** *
** http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
** *
** Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
** limitations under the License. * limitations under the License.
*/ */
#define LOG_TAG "LatinIME: jni" #define LOG_TAG "LatinIME: jni"
@ -33,8 +33,8 @@ using namespace latinime;
/* /*
* Returns the JNI version on success, -1 on failure. * Returns the JNI version on success, -1 on failure.
*/ */
jint JNI_OnLoad(JavaVM* vm, void* reserved) { jint JNI_OnLoad(JavaVM *vm, void *reserved) {
JNIEnv* env = 0; JNIEnv *env = 0;
jint result = -1; jint result = -1;
if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
@ -67,7 +67,7 @@ bail:
namespace latinime { namespace latinime {
int registerNativeMethods(JNIEnv* env, const char* className, JNINativeMethod* methods, int registerNativeMethods(JNIEnv *env, const char *className, JNINativeMethod *methods,
int numMethods) { int numMethods) {
jclass clazz = env->FindClass(className); jclass clazz = env->FindClass(className);
if (clazz == 0) { if (clazz == 0) {
@ -82,5 +82,4 @@ int registerNativeMethods(JNIEnv* env, const char* className, JNINativeMethod* m
env->DeleteLocalRef(clazz); env->DeleteLocalRef(clazz);
return JNI_TRUE; return JNI_TRUE;
} }
} // namespace latinime } // namespace latinime

View File

@ -1,19 +1,19 @@
/* /*
** *
** Copyright 2011, The Android Open Source Project * Copyright 2011, The Android Open Source Project
** *
** Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
** You may obtain a copy of the License at * You may obtain a copy of the License at
** *
** http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
** *
** Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
** limitations under the License. * limitations under the License.
*/ */
#ifndef LATINIME_JNI_COMMON_H #ifndef LATINIME_JNI_COMMON_H
#define LATINIME_JNI_COMMON_H #define LATINIME_JNI_COMMON_H
@ -54,7 +54,5 @@ inline void safeReleaseFloatArrayElements(JNIEnv *env, jfloatArray jArray, jfloa
env->ReleaseFloatArrayElements(jArray, cArray, 0); env->ReleaseFloatArrayElements(jArray, cArray, 0);
} }
} }
} // namespace latinime } // namespace latinime
#endif // LATINIME_JNI_COMMON_H #endif // LATINIME_JNI_COMMON_H

View File

@ -38,4 +38,4 @@ const int32_t AdditionalProximityChars::EN_US_ADDITIONAL_O[EN_US_ADDITIONAL_O_SI
const int32_t AdditionalProximityChars::EN_US_ADDITIONAL_U[EN_US_ADDITIONAL_U_SIZE] = { const int32_t AdditionalProximityChars::EN_US_ADDITIONAL_U[EN_US_ADDITIONAL_U_SIZE] = {
'a', 'e', 'i', 'o' 'a', 'e', 'i', 'o'
}; };
} } // namespace latinime

View File

@ -45,7 +45,7 @@ class AdditionalProximityChars {
} }
public: public:
static int getAdditionalCharsSize(const std::string* locale_str, const int32_t c) { static int getAdditionalCharsSize(const std::string *locale_str, const int32_t c) {
if (!isEnLocale(locale_str)) { if (!isEnLocale(locale_str)) {
return 0; return 0;
} }
@ -65,7 +65,7 @@ class AdditionalProximityChars {
} }
} }
static const int32_t* getAdditionalChars(const std::string *locale_str, const int32_t c) { static const int32_t *getAdditionalChars(const std::string *locale_str, const int32_t c) {
if (!isEnLocale(locale_str)) { if (!isEnLocale(locale_str)) {
return 0; return 0;
} }
@ -89,7 +89,5 @@ class AdditionalProximityChars {
return getAdditionalCharsSize(locale_str, c) > 0; return getAdditionalCharsSize(locale_str, c) > 0;
} }
}; };
} // namespace latinime
}
#endif // LATINIME_ADDITIONAL_PROXIMITY_CHARS_H #endif // LATINIME_ADDITIONAL_PROXIMITY_CHARS_H

View File

@ -18,7 +18,7 @@
namespace latinime { namespace latinime {
/** /*
* Table mapping most combined Latin, Greek, and Cyrillic characters * Table mapping most combined Latin, Greek, and Cyrillic characters
* to their base characters. If c is in range, BASE_CHARS[c] == c * to their base characters. If c is in range, BASE_CHARS[c] == c
* if c is not a combined character, or the base character if it * if c is not a combined character, or the base character if it
@ -187,8 +187,6 @@ const unsigned short BASE_CHARS[BASE_CHARS_SIZE] = {
0x0423, 0x0443, 0x0423, 0x0443, 0x0427, 0x0447, 0x04f6, 0x04f7, 0x0423, 0x0443, 0x0423, 0x0443, 0x0427, 0x0447, 0x04f6, 0x04f7,
0x042b, 0x044b, 0x04fa, 0x04fb, 0x04fc, 0x04fd, 0x04fe, 0x04ff, 0x042b, 0x044b, 0x04fa, 0x04fb, 0x04fc, 0x04fd, 0x04fe, 0x04ff,
}; };
// generated with: // generated with:
// cat UnicodeData.txt | perl -e 'while (<>) { @foo = split(/;/); $foo[5] =~ s/<.*> //; $base[hex($foo[0])] = hex($foo[5]);} for ($i = 0; $i < 0x500; $i += 8) { for ($j = $i; $j < $i + 8; $j++) { printf("0x%04x, ", $base[$j] ? $base[$j] : $j)}; print "\n"; }' // cat UnicodeData.txt | perl -e 'while (<>) { @foo = split(/;/); $foo[5] =~ s/<.*> //; $base[hex($foo[0])] = hex($foo[5]);} for ($i = 0; $i < 0x500; $i += 8) { for ($j = $i; $j < $i + 8; $j++) { printf("0x%04x, ", $base[$j] ? $base[$j] : $j)}; print "\n"; }'
} // namespace latinime } // namespace latinime

View File

@ -1,19 +1,19 @@
/* /*
** *
** Copyright 2010, The Android Open Source Project * Copyright 2010, The Android Open Source Project
** *
** Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
** You may obtain a copy of the License at * You may obtain a copy of the License at
** *
** http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
** *
** Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
** limitations under the License. * limitations under the License.
*/ */
#include <string.h> #include <string.h>
@ -103,7 +103,7 @@ int BigramDictionary::getBigrams(const int32_t *prevWord, int prevWordLength, in
// TODO: remove unused arguments, and refrain from storing stuff in members of this class // TODO: remove unused arguments, and refrain from storing stuff in members of this class
// TODO: have "in" arguments before "out" ones, and make out args explicit in the name // TODO: have "in" arguments before "out" ones, and make out args explicit in the name
const uint8_t* const root = DICT; const uint8_t *const root = DICT;
int pos = getBigramListPositionForWord(prevWord, prevWordLength, int pos = getBigramListPositionForWord(prevWord, prevWordLength,
false /* forceLowerCaseSearch */); false /* forceLowerCaseSearch */);
// getBigramListPositionForWord returns 0 if this word isn't in the dictionary or has no bigrams // getBigramListPositionForWord returns 0 if this word isn't in the dictionary or has no bigrams
@ -149,7 +149,7 @@ int BigramDictionary::getBigrams(const int32_t *prevWord, int prevWordLength, in
int BigramDictionary::getBigramListPositionForWord(const int32_t *prevWord, int BigramDictionary::getBigramListPositionForWord(const int32_t *prevWord,
const int prevWordLength, const bool forceLowerCaseSearch) const { const int prevWordLength, const bool forceLowerCaseSearch) const {
if (0 >= prevWordLength) return 0; if (0 >= prevWordLength) return 0;
const uint8_t* const root = DICT; const uint8_t *const root = DICT;
int pos = BinaryFormat::getTerminalPosition(root, prevWord, prevWordLength, int pos = BinaryFormat::getTerminalPosition(root, prevWord, prevWordLength,
forceLowerCaseSearch); forceLowerCaseSearch);
@ -170,7 +170,7 @@ int BigramDictionary::getBigramListPositionForWord(const int32_t *prevWord,
void BigramDictionary::fillBigramAddressToFrequencyMapAndFilter(const int32_t *prevWord, void BigramDictionary::fillBigramAddressToFrequencyMapAndFilter(const int32_t *prevWord,
const int prevWordLength, std::map<int, int> *map, uint8_t *filter) const { const int prevWordLength, std::map<int, int> *map, uint8_t *filter) const {
memset(filter, 0, BIGRAM_FILTER_BYTE_SIZE); memset(filter, 0, BIGRAM_FILTER_BYTE_SIZE);
const uint8_t* const root = DICT; const uint8_t *const root = DICT;
int pos = getBigramListPositionForWord(prevWord, prevWordLength, int pos = getBigramListPositionForWord(prevWord, prevWordLength,
false /* forceLowerCaseSearch */); false /* forceLowerCaseSearch */);
if (0 == pos) { if (0 == pos) {
@ -209,7 +209,7 @@ bool BigramDictionary::checkFirstCharacter(unsigned short *word, int *inputCodes
bool BigramDictionary::isValidBigram(const int32_t *word1, int length1, const int32_t *word2, bool BigramDictionary::isValidBigram(const int32_t *word1, int length1, const int32_t *word2,
int length2) const { int length2) const {
const uint8_t* const root = DICT; const uint8_t *const root = DICT;
int pos = getBigramListPositionForWord(word1, length1, false /* forceLowerCaseSearch */); int pos = getBigramListPositionForWord(word1, length1, false /* forceLowerCaseSearch */);
// getBigramListPositionForWord returns 0 if this word isn't in the dictionary or has no bigrams // getBigramListPositionForWord returns 0 if this word isn't in the dictionary or has no bigrams
if (0 == pos) return false; if (0 == pos) return false;

View File

@ -53,7 +53,5 @@ class BigramDictionary {
// TODO: Re-implement proximity correction for bigram correction // TODO: Re-implement proximity correction for bigram correction
static const int MAX_ALTERNATIVES = 1; static const int MAX_ALTERNATIVES = 1;
}; };
} // namespace latinime } // namespace latinime
#endif // LATINIME_BIGRAM_DICTIONARY_H #endif // LATINIME_BIGRAM_DICTIONARY_H

View File

@ -46,29 +46,29 @@ class BinaryFormat {
const static int CHARACTER_ARRAY_TERMINATOR_SIZE = 1; const static int CHARACTER_ARRAY_TERMINATOR_SIZE = 1;
const static int SHORTCUT_LIST_SIZE_SIZE = 2; const static int SHORTCUT_LIST_SIZE_SIZE = 2;
static int detectFormat(const uint8_t* const dict); static int detectFormat(const uint8_t *const dict);
static unsigned int getHeaderSize(const uint8_t* const dict); static unsigned int getHeaderSize(const uint8_t *const dict);
static unsigned int getFlags(const uint8_t* const dict); static unsigned int getFlags(const uint8_t *const dict);
static int getGroupCountAndForwardPointer(const uint8_t* const dict, int* pos); static int getGroupCountAndForwardPointer(const uint8_t *const dict, int *pos);
static uint8_t getFlagsAndForwardPointer(const uint8_t* const dict, int* pos); static uint8_t getFlagsAndForwardPointer(const uint8_t *const dict, int *pos);
static int32_t getCharCodeAndForwardPointer(const uint8_t* const dict, int* pos); static int32_t getCharCodeAndForwardPointer(const uint8_t *const dict, int *pos);
static int readFrequencyWithoutMovingPointer(const uint8_t* const dict, const int pos); static int readFrequencyWithoutMovingPointer(const uint8_t *const dict, const int pos);
static int skipOtherCharacters(const uint8_t* const dict, const int pos); static int skipOtherCharacters(const uint8_t *const dict, const int pos);
static int skipChildrenPosition(const uint8_t flags, const int pos); static int skipChildrenPosition(const uint8_t flags, const int pos);
static int skipFrequency(const uint8_t flags, const int pos); static int skipFrequency(const uint8_t flags, const int pos);
static int skipShortcuts(const uint8_t* const dict, const uint8_t flags, const int pos); static int skipShortcuts(const uint8_t *const dict, const uint8_t flags, const int pos);
static int skipBigrams(const uint8_t* const dict, const uint8_t flags, const int pos); static int skipBigrams(const uint8_t *const dict, const uint8_t flags, const int pos);
static int skipAllAttributes(const uint8_t* const dict, const uint8_t flags, const int pos); static int skipAllAttributes(const uint8_t *const dict, const uint8_t flags, const int pos);
static int skipChildrenPosAndAttributes(const uint8_t* const dict, const uint8_t flags, static int skipChildrenPosAndAttributes(const uint8_t *const dict, const uint8_t flags,
const int pos); const int pos);
static int readChildrenPosition(const uint8_t* const dict, const uint8_t flags, const int pos); static int readChildrenPosition(const uint8_t *const dict, const uint8_t flags, const int pos);
static bool hasChildrenInFlags(const uint8_t flags); static bool hasChildrenInFlags(const uint8_t flags);
static int getAttributeAddressAndForwardPointer(const uint8_t* const dict, const uint8_t flags, static int getAttributeAddressAndForwardPointer(const uint8_t *const dict, const uint8_t flags,
int *pos); int *pos);
static int getTerminalPosition(const uint8_t* const root, const int32_t* const inWord, static int getTerminalPosition(const uint8_t *const root, const int32_t *const inWord,
const int length, const bool forceLowerCaseSearch); const int length, const bool forceLowerCaseSearch);
static int getWordAtAddress(const uint8_t* const root, const int address, const int maxDepth, static int getWordAtAddress(const uint8_t *const root, const int address, const int maxDepth,
uint16_t* outWord, int* outUnigramFrequency); uint16_t *outWord, int *outUnigramFrequency);
static int computeFrequencyForBigram(const int unigramFreq, const int bigramFreq); static int computeFrequencyForBigram(const int unigramFreq, const int bigramFreq);
static int getProbability(const int position, const std::map<int, int> *bigramMap, static int getProbability(const int position, const std::map<int, int> *bigramMap,
const uint8_t *bigramFilter, const int unigramFreq); const uint8_t *bigramFilter, const int unigramFreq);
@ -83,7 +83,7 @@ class BinaryFormat {
const static unsigned int NO_FLAGS = 0; const static unsigned int NO_FLAGS = 0;
}; };
inline int BinaryFormat::detectFormat(const uint8_t* const dict) { inline int BinaryFormat::detectFormat(const uint8_t *const dict) {
// The magic number is stored big-endian. // The magic number is stored big-endian.
const uint32_t magicNumber = (dict[0] << 24) + (dict[1] << 16) + (dict[2] << 8) + dict[3]; const uint32_t magicNumber = (dict[0] << 24) + (dict[1] << 16) + (dict[2] << 8) + dict[3];
switch (magicNumber) { switch (magicNumber) {
@ -105,7 +105,7 @@ inline int BinaryFormat::detectFormat(const uint8_t* const dict) {
} }
} }
inline unsigned int BinaryFormat::getFlags(const uint8_t* const dict) { inline unsigned int BinaryFormat::getFlags(const uint8_t *const dict) {
switch (detectFormat(dict)) { switch (detectFormat(dict)) {
case 1: case 1:
return NO_FLAGS; return NO_FLAGS;
@ -114,7 +114,7 @@ inline unsigned int BinaryFormat::getFlags(const uint8_t* const dict) {
} }
} }
inline unsigned int BinaryFormat::getHeaderSize(const uint8_t* const dict) { inline unsigned int BinaryFormat::getHeaderSize(const uint8_t *const dict) {
switch (detectFormat(dict)) { switch (detectFormat(dict)) {
case 1: case 1:
return FORMAT_VERSION_1_HEADER_SIZE; return FORMAT_VERSION_1_HEADER_SIZE;
@ -126,17 +126,17 @@ inline unsigned int BinaryFormat::getHeaderSize(const uint8_t* const dict) {
} }
} }
inline int BinaryFormat::getGroupCountAndForwardPointer(const uint8_t* const dict, int* pos) { inline int BinaryFormat::getGroupCountAndForwardPointer(const uint8_t *const dict, int *pos) {
const int msb = dict[(*pos)++]; const int msb = dict[(*pos)++];
if (msb < 0x80) return msb; if (msb < 0x80) return msb;
return ((msb & 0x7F) << 8) | dict[(*pos)++]; return ((msb & 0x7F) << 8) | dict[(*pos)++];
} }
inline uint8_t BinaryFormat::getFlagsAndForwardPointer(const uint8_t* const dict, int* pos) { inline uint8_t BinaryFormat::getFlagsAndForwardPointer(const uint8_t *const dict, int *pos) {
return dict[(*pos)++]; return dict[(*pos)++];
} }
inline int32_t BinaryFormat::getCharCodeAndForwardPointer(const uint8_t* const dict, int* pos) { inline int32_t BinaryFormat::getCharCodeAndForwardPointer(const uint8_t *const dict, int *pos) {
const int origin = *pos; const int origin = *pos;
const int32_t character = dict[origin]; const int32_t character = dict[origin];
if (character < MINIMAL_ONE_BYTE_CHARACTER_VALUE) { if (character < MINIMAL_ONE_BYTE_CHARACTER_VALUE) {
@ -155,12 +155,12 @@ inline int32_t BinaryFormat::getCharCodeAndForwardPointer(const uint8_t* const d
} }
} }
inline int BinaryFormat::readFrequencyWithoutMovingPointer(const uint8_t* const dict, inline int BinaryFormat::readFrequencyWithoutMovingPointer(const uint8_t *const dict,
const int pos) { const int pos) {
return dict[pos]; return dict[pos];
} }
inline int BinaryFormat::skipOtherCharacters(const uint8_t* const dict, const int pos) { inline int BinaryFormat::skipOtherCharacters(const uint8_t *const dict, const int pos) {
int currentPos = pos; int currentPos = pos;
int32_t character = dict[currentPos++]; int32_t character = dict[currentPos++];
while (CHARACTER_ARRAY_TERMINATOR != character) { while (CHARACTER_ARRAY_TERMINATOR != character) {
@ -186,7 +186,7 @@ static inline int attributeAddressSize(const uint8_t flags) {
*/ */
} }
static inline int skipExistingBigrams(const uint8_t* const dict, const int pos) { static inline int skipExistingBigrams(const uint8_t *const dict, const int pos) {
int currentPos = pos; int currentPos = pos;
uint8_t flags = BinaryFormat::getFlagsAndForwardPointer(dict, &currentPos); uint8_t flags = BinaryFormat::getFlagsAndForwardPointer(dict, &currentPos);
while (flags & UnigramDictionary::FLAG_ATTRIBUTE_HAS_NEXT) { while (flags & UnigramDictionary::FLAG_ATTRIBUTE_HAS_NEXT) {
@ -203,7 +203,7 @@ static inline int childrenAddressSize(const uint8_t flags) {
/* See the note in attributeAddressSize. The same applies here */ /* See the note in attributeAddressSize. The same applies here */
} }
static inline int shortcutByteSize(const uint8_t* const dict, const int pos) { static inline int shortcutByteSize(const uint8_t *const dict, const int pos) {
return ((int)(dict[pos] << 8)) + (dict[pos + 1]); return ((int)(dict[pos] << 8)) + (dict[pos + 1]);
} }
@ -215,7 +215,7 @@ inline int BinaryFormat::skipFrequency(const uint8_t flags, const int pos) {
return UnigramDictionary::FLAG_IS_TERMINAL & flags ? pos + 1 : pos; return UnigramDictionary::FLAG_IS_TERMINAL & flags ? pos + 1 : pos;
} }
inline int BinaryFormat::skipShortcuts(const uint8_t* const dict, const uint8_t flags, inline int BinaryFormat::skipShortcuts(const uint8_t *const dict, const uint8_t flags,
const int pos) { const int pos) {
if (UnigramDictionary::FLAG_HAS_SHORTCUT_TARGETS & flags) { if (UnigramDictionary::FLAG_HAS_SHORTCUT_TARGETS & flags) {
return pos + shortcutByteSize(dict, pos); return pos + shortcutByteSize(dict, pos);
@ -224,7 +224,7 @@ inline int BinaryFormat::skipShortcuts(const uint8_t* const dict, const uint8_t
} }
} }
inline int BinaryFormat::skipBigrams(const uint8_t* const dict, const uint8_t flags, inline int BinaryFormat::skipBigrams(const uint8_t *const dict, const uint8_t flags,
const int pos) { const int pos) {
if (UnigramDictionary::FLAG_HAS_BIGRAMS & flags) { if (UnigramDictionary::FLAG_HAS_BIGRAMS & flags) {
return skipExistingBigrams(dict, pos); return skipExistingBigrams(dict, pos);
@ -233,7 +233,7 @@ inline int BinaryFormat::skipBigrams(const uint8_t* const dict, const uint8_t fl
} }
} }
inline int BinaryFormat::skipAllAttributes(const uint8_t* const dict, const uint8_t flags, inline int BinaryFormat::skipAllAttributes(const uint8_t *const dict, const uint8_t flags,
const int pos) { const int pos) {
// This function skips all attributes: shortcuts and bigrams. // This function skips all attributes: shortcuts and bigrams.
int newPos = pos; int newPos = pos;
@ -242,7 +242,7 @@ inline int BinaryFormat::skipAllAttributes(const uint8_t* const dict, const uint
return newPos; return newPos;
} }
inline int BinaryFormat::skipChildrenPosAndAttributes(const uint8_t* const dict, inline int BinaryFormat::skipChildrenPosAndAttributes(const uint8_t *const dict,
const uint8_t flags, const int pos) { const uint8_t flags, const int pos) {
int currentPos = pos; int currentPos = pos;
currentPos = skipChildrenPosition(flags, currentPos); currentPos = skipChildrenPosition(flags, currentPos);
@ -250,7 +250,7 @@ inline int BinaryFormat::skipChildrenPosAndAttributes(const uint8_t* const dict,
return currentPos; return currentPos;
} }
inline int BinaryFormat::readChildrenPosition(const uint8_t* const dict, const uint8_t flags, inline int BinaryFormat::readChildrenPosition(const uint8_t *const dict, const uint8_t flags,
const int pos) { const int pos) {
int offset = 0; int offset = 0;
switch (UnigramDictionary::MASK_GROUP_ADDRESS_TYPE & flags) { switch (UnigramDictionary::MASK_GROUP_ADDRESS_TYPE & flags) {
@ -279,7 +279,7 @@ inline bool BinaryFormat::hasChildrenInFlags(const uint8_t flags) {
!= (UnigramDictionary::MASK_GROUP_ADDRESS_TYPE & flags)); != (UnigramDictionary::MASK_GROUP_ADDRESS_TYPE & flags));
} }
inline int BinaryFormat::getAttributeAddressAndForwardPointer(const uint8_t* const dict, inline int BinaryFormat::getAttributeAddressAndForwardPointer(const uint8_t *const dict,
const uint8_t flags, int *pos) { const uint8_t flags, int *pos) {
int offset = 0; int offset = 0;
const int origin = *pos; const int origin = *pos;
@ -309,8 +309,8 @@ inline int BinaryFormat::getAttributeAddressAndForwardPointer(const uint8_t* con
// This function gets the byte position of the last chargroup of the exact matching word in the // This function gets the byte position of the last chargroup of the exact matching word in the
// dictionary. If no match is found, it returns NOT_VALID_WORD. // dictionary. If no match is found, it returns NOT_VALID_WORD.
inline int BinaryFormat::getTerminalPosition(const uint8_t* const root, inline int BinaryFormat::getTerminalPosition(const uint8_t *const root,
const int32_t* const inWord, const int length, const bool forceLowerCaseSearch) { const int32_t *const inWord, const int length, const bool forceLowerCaseSearch) {
int pos = 0; int pos = 0;
int wordPos = 0; int wordPos = 0;
@ -396,8 +396,8 @@ inline int BinaryFormat::getTerminalPosition(const uint8_t* const root,
* outUnigramFrequency: a pointer to an int to write the frequency into. * outUnigramFrequency: a pointer to an int to write the frequency into.
* Return value : the length of the word, of 0 if the word was not found. * Return value : the length of the word, of 0 if the word was not found.
*/ */
inline int BinaryFormat::getWordAtAddress(const uint8_t* const root, const int address, inline int BinaryFormat::getWordAtAddress(const uint8_t *const root, const int address,
const int maxDepth, uint16_t* outWord, int* outUnigramFrequency) { const int maxDepth, uint16_t *outWord, int *outUnigramFrequency) {
int pos = 0; int pos = 0;
int wordPos = 0; int wordPos = 0;
@ -557,7 +557,5 @@ inline int BinaryFormat::getProbability(const int position, const std::map<int,
return backoff(unigramFreq); return backoff(unigramFreq);
} }
} }
} // namespace latinime } // namespace latinime
#endif // LATINIME_BINARY_FORMAT_H #endif // LATINIME_BINARY_FORMAT_H

View File

@ -32,7 +32,5 @@ static inline bool isInFilter(const uint8_t *filter, const int position) {
const unsigned int bucket = position % BIGRAM_FILTER_MODULO; const unsigned int bucket = position % BIGRAM_FILTER_MODULO;
return filter[bucket >> 3] & (1 << (bucket & 0x7)); return filter[bucket >> 3] & (1 << (bucket & 0x7));
} }
} // namespace latinime } // namespace latinime
#endif // LATINIME_BLOOM_FILTER_H #endif // LATINIME_BLOOM_FILTER_H

View File

@ -895,5 +895,4 @@ unsigned short latin_tolower(unsigned short c) {
compare_pair_capital); compare_pair_capital);
return p ? p->small : c; return p ? p->small : c;
} }
} // namespace latinime } // namespace latinime

View File

@ -62,7 +62,5 @@ inline static unsigned short toLowerCase(const unsigned short c) {
inline static unsigned short toBaseLowerCase(const unsigned short c) { inline static unsigned short toBaseLowerCase(const unsigned short c) {
return toLowerCase(toBaseChar(c)); return toLowerCase(toBaseChar(c));
} }
} // namespace latinime } // namespace latinime
#endif // LATINIME_CHAR_UTILS_H #endif // LATINIME_CHAR_UTILS_H

View File

@ -633,7 +633,7 @@ Correction::CorrectionType Correction::processCharAndCalcState(
Correction::~Correction() { Correction::~Correction() {
} }
inline static int getQuoteCount(const unsigned short* word, const int length) { inline static int getQuoteCount(const unsigned short *word, const int length) {
int quoteCount = 0; int quoteCount = 0;
for (int i = 0; i < length; ++i) { for (int i = 0; i < length; ++i) {
if(word[i] == '\'') { if(word[i] == '\'') {
@ -653,7 +653,7 @@ inline static bool isUpperCase(unsigned short c) {
/* static */ /* static */
int Correction::RankingAlgorithm::calculateFinalProbability(const int inputIndex, int Correction::RankingAlgorithm::calculateFinalProbability(const int inputIndex,
const int outputIndex, const int freq, int* editDistanceTable, const Correction* correction, const int outputIndex, const int freq, int *editDistanceTable, const Correction *correction,
const int inputLength) { const int inputLength) {
const int excessivePos = correction->getExcessivePos(); const int excessivePos = correction->getExcessivePos();
const int typedLetterMultiplier = correction->TYPED_LETTER_MULTIPLIER; const int typedLetterMultiplier = correction->TYPED_LETTER_MULTIPLIER;
@ -677,7 +677,7 @@ int Correction::RankingAlgorithm::calculateFinalProbability(const int inputIndex
// TODO: use mExcessiveCount // TODO: use mExcessiveCount
const int matchCount = inputLength - correction->mProximityCount - excessiveCount; const int matchCount = inputLength - correction->mProximityCount - excessiveCount;
const unsigned short* word = correction->mWord; const unsigned short *word = correction->mWord;
const bool skipped = skippedCount > 0; const bool skipped = skippedCount > 0;
const int quoteDiffCount = max(0, getQuoteCount(word, outputLength) const int quoteDiffCount = max(0, getQuoteCount(word, outputLength)
@ -916,7 +916,7 @@ int Correction::RankingAlgorithm::calculateFinalProbability(const int inputIndex
/* static */ /* static */
int Correction::RankingAlgorithm::calcFreqForSplitMultipleWords( int Correction::RankingAlgorithm::calcFreqForSplitMultipleWords(
const int *freqArray, const int *wordLengthArray, const int wordCount, const int *freqArray, const int *wordLengthArray, const int wordCount,
const Correction* correction, const bool isSpaceProximity, const unsigned short *word) { const Correction *correction, const bool isSpaceProximity, const unsigned short *word) {
const int typedLetterMultiplier = correction->TYPED_LETTER_MULTIPLIER; const int typedLetterMultiplier = correction->TYPED_LETTER_MULTIPLIER;
bool firstCapitalizedWordDemotion = false; bool firstCapitalizedWordDemotion = false;
@ -1046,10 +1046,10 @@ int Correction::RankingAlgorithm::calcFreqForSplitMultipleWords(
/* Damerau-Levenshtein distance */ /* Damerau-Levenshtein distance */
inline static int editDistanceInternal( inline static int editDistanceInternal(
int* editDistanceTable, const unsigned short* before, int *editDistanceTable, const unsigned short *before,
const int beforeLength, const unsigned short* after, const int afterLength) { const int beforeLength, const unsigned short *after, const int afterLength) {
// dp[li][lo] dp[a][b] = dp[ a * lo + b] // dp[li][lo] dp[a][b] = dp[ a * lo + b]
int* dp = editDistanceTable; int *dp = editDistanceTable;
const int li = beforeLength + 1; const int li = beforeLength + 1;
const int lo = afterLength + 1; const int lo = afterLength + 1;
for (int i = 0; i < li; ++i) { for (int i = 0; i < li; ++i) {
@ -1085,8 +1085,8 @@ inline static int editDistanceInternal(
return dp[li * lo - 1]; return dp[li * lo - 1];
} }
int Correction::RankingAlgorithm::editDistance(const unsigned short* before, int Correction::RankingAlgorithm::editDistance(const unsigned short *before,
const int beforeLength, const unsigned short* after, const int afterLength) { const int beforeLength, const unsigned short *after, const int afterLength) {
int table[(beforeLength + 1) * (afterLength + 1)]; int table[(beforeLength + 1) * (afterLength + 1)];
return editDistanceInternal(table, before, beforeLength, after, afterLength); return editDistanceInternal(table, before, beforeLength, after, afterLength);
} }
@ -1114,8 +1114,8 @@ int Correction::RankingAlgorithm::editDistance(const unsigned short* before,
// So, we can normalize original score by dividing pow(2, min(b.l(),a.l())) * 255 * 2. // So, we can normalize original score by dividing pow(2, min(b.l(),a.l())) * 255 * 2.
/* static */ /* static */
float Correction::RankingAlgorithm::calcNormalizedScore(const unsigned short* before, float Correction::RankingAlgorithm::calcNormalizedScore(const unsigned short *before,
const int beforeLength, const unsigned short* after, const int afterLength, const int beforeLength, const unsigned short *after, const int afterLength,
const int score) { const int score) {
if (0 == beforeLength || 0 == afterLength) { if (0 == beforeLength || 0 == afterLength) {
return 0; return 0;

View File

@ -138,9 +138,9 @@ class Correction {
int getFreqForSplitMultipleWords( int getFreqForSplitMultipleWords(
const int *freqArray, const int *wordLengthArray, const int wordCount, const int *freqArray, const int *wordLengthArray, const int wordCount,
const bool isSpaceProximity, const unsigned short *word); const bool isSpaceProximity, const unsigned short *word);
int getFinalProbability(const int probability, unsigned short **word, int* wordLength); int getFinalProbability(const int probability, unsigned short **word, int *wordLength);
int getFinalProbabilityForSubQueue(const int probability, unsigned short **word, int getFinalProbabilityForSubQueue(const int probability, unsigned short **word,
int* wordLength, const int inputLength); int *wordLength, const int inputLength);
CorrectionType processCharAndCalcState(const int32_t c, const bool isTerminal); CorrectionType processCharAndCalcState(const int32_t c, const bool isTerminal);
@ -163,15 +163,15 @@ class Correction {
class RankingAlgorithm { class RankingAlgorithm {
public: public:
static int calculateFinalProbability(const int inputIndex, const int depth, static int calculateFinalProbability(const int inputIndex, const int depth,
const int probability, int *editDistanceTable, const Correction* correction, const int probability, int *editDistanceTable, const Correction *correction,
const int inputLength); const int inputLength);
static int calcFreqForSplitMultipleWords(const int *freqArray, const int *wordLengthArray, static int calcFreqForSplitMultipleWords(const int *freqArray, const int *wordLengthArray,
const int wordCount, const Correction* correction, const bool isSpaceProximity, const int wordCount, const Correction *correction, const bool isSpaceProximity,
const unsigned short *word); const unsigned short *word);
static float calcNormalizedScore(const unsigned short* before, const int beforeLength, static float calcNormalizedScore(const unsigned short *before, const int beforeLength,
const unsigned short* after, const int afterLength, const int score); const unsigned short *after, const int afterLength, const int score);
static int editDistance(const unsigned short* before, static int editDistance(const unsigned short *before,
const int beforeLength, const unsigned short* after, const int afterLength); const int beforeLength, const unsigned short *after, const int afterLength);
private: private:
static const int CODE_SPACE = ' '; static const int CODE_SPACE = ' ';
static const int MAX_INITIAL_SCORE = 255; static const int MAX_INITIAL_SCORE = 255;
@ -184,7 +184,7 @@ class Correction {
proximityInfo, inputCodes, inputLength, xCoordinates, yCoordinates); proximityInfo, inputCodes, inputLength, xCoordinates, yCoordinates);
} }
const unsigned short* getPrimaryInputWord() const { const unsigned short *getPrimaryInputWord() const {
return mProximityInfoState.getPrimaryInputWord(); return mProximityInfoState.getPrimaryInputWord();
} }
@ -203,7 +203,7 @@ class Correction {
inline CorrectionType processUnrelatedCorrectionType(); inline CorrectionType processUnrelatedCorrectionType();
inline void addCharToCurrentWord(const int32_t c); inline void addCharToCurrentWord(const int32_t c);
inline int getFinalProbabilityInternal(const int probability, unsigned short **word, inline int getFinalProbabilityInternal(const int probability, unsigned short **word,
int* wordLength, const int inputLength); int *wordLength, const int inputLength);
static const int TYPED_LETTER_MULTIPLIER = 2; static const int TYPED_LETTER_MULTIPLIER = 2;
static const int FULL_WORD_MULTIPLIER = 2; static const int FULL_WORD_MULTIPLIER = 2;

View File

@ -79,6 +79,5 @@ inline static void initCorrectionState(CorrectionState *state, const int rootPos
state->mSkipping = false; state->mSkipping = false;
state->mAdditionalProximityMatching = false; state->mAdditionalProximityMatching = false;
} }
} // namespace latinime } // namespace latinime
#endif // LATINIME_CORRECTION_STATE_H #endif // LATINIME_CORRECTION_STATE_H

View File

@ -1,26 +1,26 @@
/* /*
** *
** Copyright 2011, The Android Open Source Project * Copyright 2011, The Android Open Source Project
** *
** Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
** You may obtain a copy of the License at * You may obtain a copy of the License at
** *
** http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
** *
** Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
** limitations under the License. * limitations under the License.
*/ */
#ifndef LATINIME_DEBUG_H #ifndef LATINIME_DEBUG_H
#define LATINIME_DEBUG_H #define LATINIME_DEBUG_H
#include "defines.h" #include "defines.h"
static inline unsigned char* convertToUnibyteString(unsigned short* input, unsigned char* output, static inline unsigned char *convertToUnibyteString(unsigned short *input, unsigned char *output,
const unsigned int length) { const unsigned int length) {
unsigned int i = 0; unsigned int i = 0;
for (; i <= length && input[i] != 0; ++i) for (; i <= length && input[i] != 0; ++i)
@ -29,8 +29,8 @@ static inline unsigned char* convertToUnibyteString(unsigned short* input, unsig
return output; return output;
} }
static inline unsigned char* convertToUnibyteStringAndReplaceLastChar(unsigned short* input, static inline unsigned char *convertToUnibyteStringAndReplaceLastChar(unsigned short *input,
unsigned char* output, const unsigned int length, unsigned char c) { unsigned char *output, const unsigned int length, unsigned char c) {
unsigned int i = 0; unsigned int i = 0;
for (; i <= length && input[i] != 0; ++i) for (; i <= length && input[i] != 0; ++i)
output[i] = input[i] & 0xFF; output[i] = input[i] & 0xFF;
@ -39,7 +39,7 @@ static inline unsigned char* convertToUnibyteStringAndReplaceLastChar(unsigned s
return output; return output;
} }
static inline void LOGI_S16(unsigned short* string, const unsigned int length) { static inline void LOGI_S16(unsigned short *string, const unsigned int length) {
unsigned char tmp_buffer[length]; unsigned char tmp_buffer[length];
convertToUnibyteString(string, tmp_buffer, length); convertToUnibyteString(string, tmp_buffer, length);
AKLOGI(">> %s", tmp_buffer); AKLOGI(">> %s", tmp_buffer);
@ -49,7 +49,7 @@ static inline void LOGI_S16(unsigned short* string, const unsigned int length) {
// usleep(10); // usleep(10);
} }
static inline void LOGI_S16_PLUS(unsigned short* string, const unsigned int length, static inline void LOGI_S16_PLUS(unsigned short *string, const unsigned int length,
unsigned char c) { unsigned char c) {
unsigned char tmp_buffer[length+1]; unsigned char tmp_buffer[length+1];
convertToUnibyteStringAndReplaceLastChar(string, tmp_buffer, length, c); convertToUnibyteStringAndReplaceLastChar(string, tmp_buffer, length, c);
@ -58,7 +58,7 @@ static inline void LOGI_S16_PLUS(unsigned short* string, const unsigned int leng
// usleep(10); // usleep(10);
} }
static inline void printDebug(const char* tag, int* codes, int codesSize, int MAX_PROXIMITY_CHARS) { static inline void printDebug(const char *tag, int *codes, int codesSize, int MAX_PROXIMITY_CHARS) {
unsigned char *buf = (unsigned char*)malloc((1 + codesSize) * sizeof(*buf)); unsigned char *buf = (unsigned char*)malloc((1 + codesSize) * sizeof(*buf));
buf[codesSize] = 0; buf[codesSize] = 0;
@ -68,5 +68,4 @@ static inline void printDebug(const char* tag, int* codes, int codesSize, int MA
free(buf); free(buf);
} }
#endif // LATINIME_DEBUG_H #endif // LATINIME_DEBUG_H

View File

@ -1,19 +1,19 @@
/* /*
** *
** Copyright 2010, The Android Open Source Project * Copyright 2010, The Android Open Source Project
** *
** Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
** You may obtain a copy of the License at * You may obtain a copy of the License at
** *
** http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
** *
** Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
** limitations under the License. * limitations under the License.
*/ */
#ifndef LATINIME_DEFINES_H #ifndef LATINIME_DEFINES_H
#define LATINIME_DEFINES_H #define LATINIME_DEFINES_H
@ -26,7 +26,7 @@
#define DUMP_WORD(word, length) do { dumpWord(word, length); } while(0) #define DUMP_WORD(word, length) do { dumpWord(word, length); } while(0)
#define DUMP_WORD_INT(word, length) do { dumpWordInt(word, length); } while(0) #define DUMP_WORD_INT(word, length) do { dumpWordInt(word, length); } while(0)
static inline void dumpWord(const unsigned short* word, const int length) { static inline void dumpWord(const unsigned short *word, const int length) {
static char charBuf[50]; static char charBuf[50];
for (int i = 0; i < length; ++i) { for (int i = 0; i < length; ++i) {
@ -36,7 +36,7 @@ static inline void dumpWord(const unsigned short* word, const int length) {
AKLOGI("[ %s ]", charBuf); AKLOGI("[ %s ]", charBuf);
} }
static inline void dumpWordInt(const int* word, const int length) { static inline void dumpWordInt(const int *word, const int length) {
static char charBuf[50]; static char charBuf[50];
for (int i = 0; i < length; ++i) { for (int i = 0; i < length; ++i) {
@ -313,5 +313,4 @@ typedef enum {
// Additional proximity char which can differ by language. // Additional proximity char which can differ by language.
ADDITIONAL_PROXIMITY_CHAR ADDITIONAL_PROXIMITY_CHAR
} ProximityType; } ProximityType;
#endif // LATINIME_DEFINES_H #endif // LATINIME_DEFINES_H

View File

@ -1,19 +1,19 @@
/* /*
** *
** Copyright 2009, The Android Open Source Project * Copyright (C) 2009, The Android Open Source Project
** *
** Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
** You may obtain a copy of the License at * You may obtain a copy of the License at
** *
** http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
** *
** Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
** limitations under the License. * limitations under the License.
*/ */
#include <stdio.h> #include <stdio.h>
@ -63,5 +63,4 @@ bool Dictionary::isValidBigram(const int32_t *word1, int length1, const int32_t
int length2) const { int length2) const {
return mBigramDictionary->isValidBigram(word1, length1, word2, length2); return mBigramDictionary->isValidBigram(word1, length1, word2, length2);
} }
} // namespace latinime } // namespace latinime

View File

@ -113,5 +113,4 @@ inline int Dictionary::wideStrLen(unsigned short *str) {
return end - str; return end - str;
} }
} // namespace latinime } // namespace latinime
#endif // LATINIME_DICTIONARY_H #endif // LATINIME_DICTIONARY_H

View File

@ -110,7 +110,7 @@ bool ProximityInfo::hasSpaceProximity(const int x, const int y) const {
if (DEBUG_PROXIMITY_INFO) { if (DEBUG_PROXIMITY_INFO) {
AKLOGI("hasSpaceProximity: index %d, %d, %d", startIndex, x, y); AKLOGI("hasSpaceProximity: index %d, %d, %d", startIndex, x, y);
} }
int32_t* proximityCharsArray = mProximityCharsArray; int32_t *proximityCharsArray = mProximityCharsArray;
for (int i = 0; i < MAX_PROXIMITY_CHARS_SIZE; ++i) { for (int i = 0; i < MAX_PROXIMITY_CHARS_SIZE; ++i) {
if (DEBUG_PROXIMITY_INFO) { if (DEBUG_PROXIMITY_INFO) {
AKLOGI("Index: %d", mProximityCharsArray[startIndex + i]); AKLOGI("Index: %d", mProximityCharsArray[startIndex + i]);
@ -171,7 +171,7 @@ void ProximityInfo::calculateNearbyKeyCodes(
return; return;
} }
const int32_t* additionalProximityChars = const int32_t *additionalProximityChars =
AdditionalProximityChars::getAdditionalChars(&mLocaleStr, primaryKey); AdditionalProximityChars::getAdditionalChars(&mLocaleStr, primaryKey);
for (int j = 0; j < additionalProximitySize; ++j) { for (int j = 0; j < additionalProximitySize; ++j) {
const int32_t ac = additionalProximityChars[j]; const int32_t ac = additionalProximityChars[j];

View File

@ -141,7 +141,5 @@ class ProximityInfo {
int mCodeToKeyIndex[MAX_CHAR_CODE + 1]; int mCodeToKeyIndex[MAX_CHAR_CODE + 1];
// TODO: move to correction.h // TODO: move to correction.h
}; };
} // namespace latinime } // namespace latinime
#endif // LATINIME_PROXIMITY_INFO_H #endif // LATINIME_PROXIMITY_INFO_H

View File

@ -28,8 +28,8 @@
namespace latinime { namespace latinime {
void ProximityInfoState::initInputParams( void ProximityInfoState::initInputParams(
const ProximityInfo* proximityInfo, const int32_t* inputCodes, const int inputLength, const ProximityInfo *proximityInfo, const int32_t *inputCodes, const int inputLength,
const int* xCoordinates, const int* yCoordinates) { const int *xCoordinates, const int *yCoordinates) {
mProximityInfo = proximityInfo; mProximityInfo = proximityInfo;
mHasTouchPositionCorrectionData = proximityInfo->hasTouchPositionCorrectionData(); mHasTouchPositionCorrectionData = proximityInfo->hasTouchPositionCorrectionData();
mMostCommonKeyWidthSquare = proximityInfo->getMostCommonKeyWidthSquare(); mMostCommonKeyWidthSquare = proximityInfo->getMostCommonKeyWidthSquare();

View File

@ -43,14 +43,14 @@ class ProximityInfoState {
// Defined in proximity_info_state.cpp // // Defined in proximity_info_state.cpp //
///////////////////////////////////////// /////////////////////////////////////////
void initInputParams( void initInputParams(
const ProximityInfo* proximityInfo, const int32_t* inputCodes, const int inputLength, const ProximityInfo *proximityInfo, const int32_t *inputCodes, const int inputLength,
const int* xCoordinates, const int* yCoordinates); const int *xCoordinates, const int *yCoordinates);
///////////////////////////////////////// /////////////////////////////////////////
// Defined here // // Defined here //
///////////////////////////////////////// /////////////////////////////////////////
ProximityInfoState() {}; ProximityInfoState() {};
inline const int* getProximityCharsAt(const int index) const { inline const int *getProximityCharsAt(const int index) const {
return mInputCodes + (index * MAX_PROXIMITY_CHARS_SIZE_INTERNAL); return mInputCodes + (index * MAX_PROXIMITY_CHARS_SIZE_INTERNAL);
} }
@ -154,7 +154,7 @@ class ProximityInfoState {
inputIndex * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + proximityIndex]; inputIndex * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + proximityIndex];
} }
inline const unsigned short* getPrimaryInputWord() const { inline const unsigned short *getPrimaryInputWord() const {
return mPrimaryInputWord; return mPrimaryInputWord;
} }
@ -215,7 +215,5 @@ class ProximityInfoState {
int mInputLength; int mInputLength;
unsigned short mPrimaryInputWord[MAX_WORD_LENGTH_INTERNAL]; unsigned short mPrimaryInputWord[MAX_WORD_LENGTH_INTERNAL];
}; };
} // namespace latinime } // namespace latinime
#endif // LATINIME_PROXIMITY_INFO_STATE_H #endif // LATINIME_PROXIMITY_INFO_STATE_H

View File

@ -29,12 +29,12 @@ namespace latinime {
class TerminalAttributes { class TerminalAttributes {
public: public:
class ShortcutIterator { class ShortcutIterator {
const uint8_t* const mDict; const uint8_t *const mDict;
bool mHasNextShortcutTarget; bool mHasNextShortcutTarget;
int mPos; int mPos;
public: public:
ShortcutIterator(const uint8_t* dict, const int pos, const uint8_t flags) : mDict(dict), ShortcutIterator(const uint8_t *dict, const int pos, const uint8_t flags) : mDict(dict),
mPos(pos) { mPos(pos) {
mHasNextShortcutTarget = (0 != (flags & UnigramDictionary::FLAG_HAS_SHORTCUT_TARGETS)); mHasNextShortcutTarget = (0 != (flags & UnigramDictionary::FLAG_HAS_SHORTCUT_TARGETS));
} }
@ -46,7 +46,7 @@ class TerminalAttributes {
// Gets the shortcut target itself as a uint16_t string. For parameters and return value // Gets the shortcut target itself as a uint16_t string. For parameters and return value
// see BinaryFormat::getWordAtAddress. // see BinaryFormat::getWordAtAddress.
// TODO: make the output an uint32_t* to handle the whole unicode range. // TODO: make the output an uint32_t* to handle the whole unicode range.
inline int getNextShortcutTarget(const int maxDepth, uint16_t* outWord) { inline int getNextShortcutTarget(const int maxDepth, uint16_t *outWord) {
const int shortcutFlags = BinaryFormat::getFlagsAndForwardPointer(mDict, &mPos); const int shortcutFlags = BinaryFormat::getFlagsAndForwardPointer(mDict, &mPos);
mHasNextShortcutTarget = mHasNextShortcutTarget =
0 != (shortcutFlags & UnigramDictionary::FLAG_ATTRIBUTE_HAS_NEXT); 0 != (shortcutFlags & UnigramDictionary::FLAG_ATTRIBUTE_HAS_NEXT);
@ -63,12 +63,12 @@ class TerminalAttributes {
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(TerminalAttributes); DISALLOW_IMPLICIT_CONSTRUCTORS(TerminalAttributes);
const uint8_t* const mDict; const uint8_t *const mDict;
const uint8_t mFlags; const uint8_t mFlags;
const int mStartPos; const int mStartPos;
public: public:
TerminalAttributes(const uint8_t* const dict, const uint8_t flags, const int pos) : TerminalAttributes(const uint8_t *const dict, const uint8_t flags, const int pos) :
mDict(dict), mFlags(flags), mStartPos(pos) { mDict(dict), mFlags(flags), mStartPos(pos) {
} }
@ -79,5 +79,4 @@ class TerminalAttributes {
} }
}; };
} // namespace latinime } // namespace latinime
#endif // LATINIME_TERMINAL_ATTRIBUTES_H #endif // LATINIME_TERMINAL_ATTRIBUTES_H

View File

@ -1,19 +1,19 @@
/* /*
** *
** Copyright 2010, The Android Open Source Project * Copyright 2010, The Android Open Source Project
** *
** Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
** You may obtain a copy of the License at * You may obtain a copy of the License at
** *
** http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
** *
** Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
** limitations under the License. * limitations under the License.
*/ */
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
@ -40,7 +40,7 @@ const UnigramDictionary::digraph_t UnigramDictionary::FRENCH_LIGATURES_DIGRAPHS[
{ 'o', 'e', 0x0153 } }; // U+0153 : LATIN SMALL LIGATURE OE { 'o', 'e', 0x0153 } }; // U+0153 : LATIN SMALL LIGATURE OE
// TODO: check the header // TODO: check the header
UnigramDictionary::UnigramDictionary(const uint8_t* const streamStart, int typedLetterMultiplier, UnigramDictionary::UnigramDictionary(const uint8_t *const streamStart, int typedLetterMultiplier,
int fullWordMultiplier, int maxWordLength, int maxWords, const unsigned int flags) int fullWordMultiplier, int maxWordLength, int maxWords, const unsigned int flags)
: DICT_ROOT(streamStart), MAX_WORD_LENGTH(maxWordLength), MAX_WORDS(maxWords), : DICT_ROOT(streamStart), MAX_WORD_LENGTH(maxWordLength), MAX_WORDS(maxWords),
TYPED_LETTER_MULTIPLIER(typedLetterMultiplier), FULL_WORD_MULTIPLIER(fullWordMultiplier), TYPED_LETTER_MULTIPLIER(typedLetterMultiplier), FULL_WORD_MULTIPLIER(fullWordMultiplier),
@ -68,7 +68,7 @@ static inline void addWord(
// Return the replacement code point for a digraph, or 0 if none. // Return the replacement code point for a digraph, or 0 if none.
int UnigramDictionary::getDigraphReplacement(const int *codes, const int i, const int codesSize, int UnigramDictionary::getDigraphReplacement(const int *codes, const int i, const int codesSize,
const digraph_t* const digraphs, const unsigned int digraphsSize) const { const digraph_t *const digraphs, const unsigned int digraphsSize) const {
// There can't be a digraph if we don't have at least 2 characters to examine // There can't be a digraph if we don't have at least 2 characters to examine
if (i + 2 > codesSize) return false; if (i + 2 > codesSize) return false;
@ -103,7 +103,7 @@ void UnigramDictionary::getWordWithDigraphSuggestionsRec(ProximityInfo *proximit
const bool useFullEditDistance, const int *codesSrc, const bool useFullEditDistance, const int *codesSrc,
const int codesRemain, const int currentDepth, int *codesDest, Correction *correction, const int codesRemain, const int currentDepth, int *codesDest, Correction *correction,
WordsPriorityQueuePool *queuePool, WordsPriorityQueuePool *queuePool,
const digraph_t* const digraphs, const unsigned int digraphsSize) const { const digraph_t *const digraphs, const unsigned int digraphsSize) const {
const int startIndex = codesDest - codesBuffer; const int startIndex = codesDest - codesBuffer;
if (currentDepth < MAX_DIGRAPH_SEARCH_DEPTH) { if (currentDepth < MAX_DIGRAPH_SEARCH_DEPTH) {
@ -222,7 +222,7 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo,
AKLOGI("Returning %d words", suggestedWordsCount); AKLOGI("Returning %d words", suggestedWordsCount);
/// Print the returned words /// Print the returned words
for (int j = 0; j < suggestedWordsCount; ++j) { for (int j = 0; j < suggestedWordsCount; ++j) {
short unsigned int* w = outWords + j * MAX_WORD_LENGTH; short unsigned int *w = outWords + j * MAX_WORD_LENGTH;
char s[MAX_WORD_LENGTH]; char s[MAX_WORD_LENGTH];
for (int i = 0; i <= MAX_WORD_LENGTH; i++) s[i] = w[i]; for (int i = 0; i <= MAX_WORD_LENGTH; i++) s[i] = w[i];
(void)s; (void)s;
@ -259,7 +259,7 @@ void UnigramDictionary::getWordSuggestions(ProximityInfo *proximityInfo,
PROF_START(4); PROF_START(4);
bool hasAutoCorrectionCandidate = false; bool hasAutoCorrectionCandidate = false;
WordsPriorityQueue* masterQueue = queuePool->getMasterQueue(); WordsPriorityQueue *masterQueue = queuePool->getMasterQueue();
if (masterQueue->size() > 0) { if (masterQueue->size() > 0) {
float nsForMaster = masterQueue->getHighestNormalizedScore( float nsForMaster = masterQueue->getHighestNormalizedScore(
correction->getPrimaryInputWord(), inputLength, 0, 0, 0); correction->getPrimaryInputWord(), inputLength, 0, 0, 0);
@ -284,11 +284,11 @@ void UnigramDictionary::getWordSuggestions(ProximityInfo *proximityInfo,
if (DEBUG_DICT) { if (DEBUG_DICT) {
queuePool->dumpSubQueue1TopSuggestions(); queuePool->dumpSubQueue1TopSuggestions();
for (int i = 0; i < SUB_QUEUE_MAX_COUNT; ++i) { for (int i = 0; i < SUB_QUEUE_MAX_COUNT; ++i) {
WordsPriorityQueue* queue = queuePool->getSubQueue(FIRST_WORD_INDEX, i); WordsPriorityQueue *queue = queuePool->getSubQueue(FIRST_WORD_INDEX, i);
if (queue->size() > 0) { if (queue->size() > 0) {
WordsPriorityQueue::SuggestedWord* sw = queue->top(); WordsPriorityQueue::SuggestedWord *sw = queue->top();
const int score = sw->mScore; const int score = sw->mScore;
const unsigned short* word = sw->mWord; const unsigned short *word = sw->mWord;
const int wordLength = sw->mWordLength; const int wordLength = sw->mWordLength;
float ns = Correction::RankingAlgorithm::calcNormalizedScore( float ns = Correction::RankingAlgorithm::calcNormalizedScore(
correction->getPrimaryInputWord(), i, word, wordLength, score); correction->getPrimaryInputWord(), i, word, wordLength, score);
@ -383,7 +383,7 @@ inline void UnigramDictionary::onTerminal(const int probability,
const bool addToSubQueue = inputIndex < SUB_QUEUE_MAX_COUNT; const bool addToSubQueue = inputIndex < SUB_QUEUE_MAX_COUNT;
int wordLength; int wordLength;
unsigned short* wordPointer; unsigned short *wordPointer;
if ((currentWordIndex == FIRST_WORD_INDEX) && addToMasterQueue) { if ((currentWordIndex == FIRST_WORD_INDEX) && addToMasterQueue) {
WordsPriorityQueue *masterQueue = queuePool->getMasterQueue(); WordsPriorityQueue *masterQueue = queuePool->getMasterQueue();
@ -430,11 +430,11 @@ inline void UnigramDictionary::onTerminal(const int probability,
int UnigramDictionary::getSubStringSuggestion( int UnigramDictionary::getSubStringSuggestion(
ProximityInfo *proximityInfo, const int *xcoordinates, const int *ycoordinates, ProximityInfo *proximityInfo, const int *xcoordinates, const int *ycoordinates,
const int *codes, const bool useFullEditDistance, Correction *correction, const int *codes, const bool useFullEditDistance, Correction *correction,
WordsPriorityQueuePool* queuePool, const int inputLength, WordsPriorityQueuePool *queuePool, const int inputLength,
const bool hasAutoCorrectionCandidate, const int currentWordIndex, const bool hasAutoCorrectionCandidate, const int currentWordIndex,
const int inputWordStartPos, const int inputWordLength, const int inputWordStartPos, const int inputWordLength,
const int outputWordStartPos, const bool isSpaceProximity, int *freqArray, const int outputWordStartPos, const bool isSpaceProximity, int *freqArray,
int*wordLengthArray, unsigned short* outputWord, int *outputWordLength) const { int*wordLengthArray, unsigned short *outputWord, int *outputWordLength) const {
if (inputWordLength > MULTIPLE_WORDS_SUGGESTION_MAX_WORD_LENGTH) { if (inputWordLength > MULTIPLE_WORDS_SUGGESTION_MAX_WORD_LENGTH) {
return FLAG_MULTIPLE_SUGGEST_ABORT; return FLAG_MULTIPLE_SUGGEST_ABORT;
} }
@ -477,7 +477,7 @@ int UnigramDictionary::getSubStringSuggestion(
// TODO: Remove the safety net above // // TODO: Remove the safety net above //
////////////////////////////////////////////// //////////////////////////////////////////////
unsigned short* tempOutputWord = 0; unsigned short *tempOutputWord = 0;
int nextWordLength = 0; int nextWordLength = 0;
// TODO: Optimize init suggestion // TODO: Optimize init suggestion
initSuggestions(proximityInfo, xcoordinates, ycoordinates, codes, initSuggestions(proximityInfo, xcoordinates, ycoordinates, codes,
@ -508,7 +508,7 @@ int UnigramDictionary::getSubStringSuggestion(
} }
} }
} }
WordsPriorityQueue* queue = queuePool->getSubQueue(currentWordIndex, inputWordLength); WordsPriorityQueue *queue = queuePool->getSubQueue(currentWordIndex, inputWordLength);
// TODO: Return the correct value depending on doAutoCompletion // TODO: Return the correct value depending on doAutoCompletion
if (!queue || queue->size() <= 0) { if (!queue || queue->size() <= 0) {
return FLAG_MULTIPLE_SUGGEST_ABORT; return FLAG_MULTIPLE_SUGGEST_ABORT;
@ -579,10 +579,10 @@ int UnigramDictionary::getSubStringSuggestion(
void UnigramDictionary::getMultiWordsSuggestionRec(ProximityInfo *proximityInfo, void UnigramDictionary::getMultiWordsSuggestionRec(ProximityInfo *proximityInfo,
const int *xcoordinates, const int *ycoordinates, const int *codes, const int *xcoordinates, const int *ycoordinates, const int *codes,
const bool useFullEditDistance, const int inputLength, const bool useFullEditDistance, const int inputLength,
Correction *correction, WordsPriorityQueuePool* queuePool, Correction *correction, WordsPriorityQueuePool *queuePool,
const bool hasAutoCorrectionCandidate, const int startInputPos, const int startWordIndex, const bool hasAutoCorrectionCandidate, const int startInputPos, const int startWordIndex,
const int outputWordLength, int *freqArray, int* wordLengthArray, const int outputWordLength, int *freqArray, int *wordLengthArray,
unsigned short* outputWord) const { unsigned short *outputWord) const {
if (startWordIndex >= (MULTIPLE_WORDS_SUGGESTION_MAX_WORDS - 1)) { if (startWordIndex >= (MULTIPLE_WORDS_SUGGESTION_MAX_WORDS - 1)) {
// Return if the last word index // Return if the last word index
return; return;
@ -660,7 +660,7 @@ void UnigramDictionary::getMultiWordsSuggestionRec(ProximityInfo *proximityInfo,
void UnigramDictionary::getSplitMultipleWordsSuggestions(ProximityInfo *proximityInfo, void UnigramDictionary::getSplitMultipleWordsSuggestions(ProximityInfo *proximityInfo,
const int *xcoordinates, const int *ycoordinates, const int *codes, const int *xcoordinates, const int *ycoordinates, const int *codes,
const bool useFullEditDistance, const int inputLength, const bool useFullEditDistance, const int inputLength,
Correction *correction, WordsPriorityQueuePool* queuePool, Correction *correction, WordsPriorityQueuePool *queuePool,
const bool hasAutoCorrectionCandidate) const { const bool hasAutoCorrectionCandidate) const {
if (inputLength >= MAX_WORD_LENGTH) return; if (inputLength >= MAX_WORD_LENGTH) return;
if (DEBUG_DICT) { if (DEBUG_DICT) {
@ -705,9 +705,9 @@ inline int UnigramDictionary::getMostFrequentWordLike(const int startInputIndex,
// In and out parameters may point to the same location. This function takes care // In and out parameters may point to the same location. This function takes care
// not to use any input parameters after it wrote into its outputs. // not to use any input parameters after it wrote into its outputs.
static inline bool testCharGroupForContinuedLikeness(const uint8_t flags, static inline bool testCharGroupForContinuedLikeness(const uint8_t flags,
const uint8_t* const root, const int startPos, const uint8_t *const root, const int startPos,
const uint16_t* const inWord, const int startInputIndex, const uint16_t *const inWord, const int startInputIndex,
int32_t* outNewWord, int* outInputIndex, int* outPos) { int32_t *outNewWord, int *outInputIndex, int *outPos) {
const bool hasMultipleChars = (0 != (UnigramDictionary::FLAG_HAS_MULTIPLE_CHARS & flags)); const bool hasMultipleChars = (0 != (UnigramDictionary::FLAG_HAS_MULTIPLE_CHARS & flags));
int pos = startPos; int pos = startPos;
int32_t character = BinaryFormat::getCharCodeAndForwardPointer(root, &pos); int32_t character = BinaryFormat::getCharCodeAndForwardPointer(root, &pos);
@ -743,8 +743,8 @@ static inline bool testCharGroupForContinuedLikeness(const uint8_t flags,
// It will compare the frequency to the max frequency, and if greater, will // It will compare the frequency to the max frequency, and if greater, will
// copy the word into the output buffer. In output value maxFreq, it will // copy the word into the output buffer. In output value maxFreq, it will
// write the new maximum frequency if it changed. // write the new maximum frequency if it changed.
static inline void onTerminalWordLike(const int freq, int32_t* newWord, const int length, static inline void onTerminalWordLike(const int freq, int32_t *newWord, const int length,
short unsigned int* outWord, int* maxFreq) { short unsigned int *outWord, int *maxFreq) {
if (freq > *maxFreq) { if (freq > *maxFreq) {
for (int q = 0; q < length; ++q) for (int q = 0; q < length; ++q)
outWord[q] = newWord[q]; outWord[q] = newWord[q];
@ -755,12 +755,12 @@ static inline void onTerminalWordLike(const int freq, int32_t* newWord, const in
// Will find the highest frequency of the words like the one passed as an argument, // Will find the highest frequency of the words like the one passed as an argument,
// that is, everything that only differs by case/accents. // that is, everything that only differs by case/accents.
int UnigramDictionary::getMostFrequentWordLikeInner(const uint16_t * const inWord, int UnigramDictionary::getMostFrequentWordLikeInner(const uint16_t *const inWord,
const int length, short unsigned int* outWord) const { const int length, short unsigned int *outWord) const {
int32_t newWord[MAX_WORD_LENGTH_INTERNAL]; int32_t newWord[MAX_WORD_LENGTH_INTERNAL];
int depth = 0; int depth = 0;
int maxFreq = -1; int maxFreq = -1;
const uint8_t* const root = DICT_ROOT; const uint8_t *const root = DICT_ROOT;
int stackChildCount[MAX_WORD_LENGTH_INTERNAL]; int stackChildCount[MAX_WORD_LENGTH_INTERNAL];
int stackInputIndex[MAX_WORD_LENGTH_INTERNAL]; int stackInputIndex[MAX_WORD_LENGTH_INTERNAL];
int stackSiblingPos[MAX_WORD_LENGTH_INTERNAL]; int stackSiblingPos[MAX_WORD_LENGTH_INTERNAL];
@ -816,8 +816,8 @@ int UnigramDictionary::getMostFrequentWordLikeInner(const uint16_t * const inWor
return maxFreq; return maxFreq;
} }
int UnigramDictionary::getFrequency(const int32_t* const inWord, const int length) const { int UnigramDictionary::getFrequency(const int32_t *const inWord, const int length) const {
const uint8_t* const root = DICT_ROOT; const uint8_t *const root = DICT_ROOT;
int pos = BinaryFormat::getTerminalPosition(root, inWord, length, int pos = BinaryFormat::getTerminalPosition(root, inWord, length,
false /* forceLowerCaseSearch */); false /* forceLowerCaseSearch */);
if (NOT_VALID_WORD == pos) { if (NOT_VALID_WORD == pos) {
@ -991,5 +991,4 @@ inline bool UnigramDictionary::processCurrentNode(const int initialPos,
*newChildrenPosition = childrenPos; *newChildrenPosition = childrenPos;
return true; return true;
} }
} // namespace latinime } // namespace latinime

View File

@ -73,9 +73,9 @@ class UnigramDictionary {
static const int FLAG_MULTIPLE_SUGGEST_ABORT = 0; static const int FLAG_MULTIPLE_SUGGEST_ABORT = 0;
static const int FLAG_MULTIPLE_SUGGEST_SKIP = 1; static const int FLAG_MULTIPLE_SUGGEST_SKIP = 1;
static const int FLAG_MULTIPLE_SUGGEST_CONTINUE = 2; static const int FLAG_MULTIPLE_SUGGEST_CONTINUE = 2;
UnigramDictionary(const uint8_t* const streamStart, int typedLetterMultipler, UnigramDictionary(const uint8_t *const streamStart, int typedLetterMultipler,
int fullWordMultiplier, int maxWordLength, int maxWords, const unsigned int flags); int fullWordMultiplier, int maxWordLength, int maxWords, const unsigned int flags);
int getFrequency(const int32_t* const inWord, const int length) const; int getFrequency(const int32_t *const inWord, const int length) const;
int getBigramPosition(int pos, unsigned short *word, int offset, int length) const; int getBigramPosition(int pos, unsigned short *word, int offset, int length) const;
int getSuggestions( int getSuggestions(
ProximityInfo *proximityInfo, const int *xcoordinates, const int *ycoordinates, ProximityInfo *proximityInfo, const int *xcoordinates, const int *ycoordinates,
@ -92,14 +92,14 @@ class UnigramDictionary {
const bool useFullEditDistance, Correction *correction, const bool useFullEditDistance, Correction *correction,
WordsPriorityQueuePool *queuePool) const; WordsPriorityQueuePool *queuePool) const;
int getDigraphReplacement(const int *codes, const int i, const int codesSize, int getDigraphReplacement(const int *codes, const int i, const int codesSize,
const digraph_t* const digraphs, const unsigned int digraphsSize) const; const digraph_t *const digraphs, const unsigned int digraphsSize) const;
void getWordWithDigraphSuggestionsRec(ProximityInfo *proximityInfo, void getWordWithDigraphSuggestionsRec(ProximityInfo *proximityInfo,
const int *xcoordinates, const int* ycoordinates, const int *codesBuffer, const int *xcoordinates, const int *ycoordinates, const int *codesBuffer,
int *xCoordinatesBuffer, int *yCoordinatesBuffer, const int codesBufferSize, int *xCoordinatesBuffer, int *yCoordinatesBuffer, const int codesBufferSize,
const std::map<int, int> *bigramMap, const uint8_t *bigramFilter, const std::map<int, int> *bigramMap, const uint8_t *bigramFilter,
const bool useFullEditDistance, const int* codesSrc, const int codesRemain, const bool useFullEditDistance, const int *codesSrc, const int codesRemain,
const int currentDepth, int* codesDest, Correction *correction, const int currentDepth, int *codesDest, Correction *correction,
WordsPriorityQueuePool* queuePool, const digraph_t* const digraphs, WordsPriorityQueuePool *queuePool, const digraph_t *const digraphs,
const unsigned int digraphsSize) const; const unsigned int digraphsSize) const;
void initSuggestions(ProximityInfo *proximityInfo, const int *xcoordinates, void initSuggestions(ProximityInfo *proximityInfo, const int *xcoordinates,
const int *ycoordinates, const int *codes, const int codesSize, const int *ycoordinates, const int *codes, const int codesSize,
@ -107,16 +107,16 @@ class UnigramDictionary {
void getOneWordSuggestions(ProximityInfo *proximityInfo, const int *xcoordinates, void getOneWordSuggestions(ProximityInfo *proximityInfo, const int *xcoordinates,
const int *ycoordinates, const int *codes, const std::map<int, int> *bigramMap, const int *ycoordinates, const int *codes, const std::map<int, int> *bigramMap,
const uint8_t *bigramFilter, const bool useFullEditDistance, const int inputLength, const uint8_t *bigramFilter, const bool useFullEditDistance, const int inputLength,
Correction *correction, WordsPriorityQueuePool* queuePool) const; Correction *correction, WordsPriorityQueuePool *queuePool) const;
void getSuggestionCandidates( void getSuggestionCandidates(
const bool useFullEditDistance, const int inputLength, const bool useFullEditDistance, const int inputLength,
const std::map<int, int> *bigramMap, const uint8_t *bigramFilter, const std::map<int, int> *bigramMap, const uint8_t *bigramFilter,
Correction *correction, WordsPriorityQueuePool* queuePool, const bool doAutoCompletion, Correction *correction, WordsPriorityQueuePool *queuePool, const bool doAutoCompletion,
const int maxErrors, const int currentWordIndex) const; const int maxErrors, const int currentWordIndex) const;
void getSplitMultipleWordsSuggestions(ProximityInfo *proximityInfo, void getSplitMultipleWordsSuggestions(ProximityInfo *proximityInfo,
const int *xcoordinates, const int *ycoordinates, const int *codes, const int *xcoordinates, const int *ycoordinates, const int *codes,
const bool useFullEditDistance, const int inputLength, const bool useFullEditDistance, const int inputLength,
Correction *correction, WordsPriorityQueuePool* queuePool, Correction *correction, WordsPriorityQueuePool *queuePool,
const bool hasAutoCorrectionCandidate) const; const bool hasAutoCorrectionCandidate) const;
void onTerminal(const int freq, const TerminalAttributes& terminalAttributes, void onTerminal(const int freq, const TerminalAttributes& terminalAttributes,
Correction *correction, WordsPriorityQueuePool *queuePool, const bool addToMasterQueue, Correction *correction, WordsPriorityQueuePool *queuePool, const bool addToMasterQueue,
@ -128,25 +128,25 @@ class UnigramDictionary {
const int currentWordIndex) const; const int currentWordIndex) const;
int getMostFrequentWordLike(const int startInputIndex, const int inputLength, int getMostFrequentWordLike(const int startInputIndex, const int inputLength,
Correction *correction, unsigned short *word) const; Correction *correction, unsigned short *word) const;
int getMostFrequentWordLikeInner(const uint16_t* const inWord, const int length, int getMostFrequentWordLikeInner(const uint16_t *const inWord, const int length,
short unsigned int *outWord) const; short unsigned int *outWord) const;
int getSubStringSuggestion( int getSubStringSuggestion(
ProximityInfo *proximityInfo, const int *xcoordinates, const int *ycoordinates, ProximityInfo *proximityInfo, const int *xcoordinates, const int *ycoordinates,
const int *codes, const bool useFullEditDistance, Correction *correction, const int *codes, const bool useFullEditDistance, Correction *correction,
WordsPriorityQueuePool* queuePool, const int inputLength, WordsPriorityQueuePool *queuePool, const int inputLength,
const bool hasAutoCorrectionCandidate, const int currentWordIndex, const bool hasAutoCorrectionCandidate, const int currentWordIndex,
const int inputWordStartPos, const int inputWordLength, const int inputWordStartPos, const int inputWordLength,
const int outputWordStartPos, const bool isSpaceProximity, int *freqArray, const int outputWordStartPos, const bool isSpaceProximity, int *freqArray,
int *wordLengthArray, unsigned short* outputWord, int *outputWordLength) const; int *wordLengthArray, unsigned short *outputWord, int *outputWordLength) const;
void getMultiWordsSuggestionRec(ProximityInfo *proximityInfo, void getMultiWordsSuggestionRec(ProximityInfo *proximityInfo,
const int *xcoordinates, const int *ycoordinates, const int *codes, const int *xcoordinates, const int *ycoordinates, const int *codes,
const bool useFullEditDistance, const int inputLength, const bool useFullEditDistance, const int inputLength,
Correction *correction, WordsPriorityQueuePool* queuePool, Correction *correction, WordsPriorityQueuePool *queuePool,
const bool hasAutoCorrectionCandidate, const int startPos, const int startWordIndex, const bool hasAutoCorrectionCandidate, const int startPos, const int startWordIndex,
const int outputWordLength, int *freqArray, int* wordLengthArray, const int outputWordLength, int *freqArray, int *wordLengthArray,
unsigned short* outputWord) const; unsigned short *outputWord) const;
const uint8_t* const DICT_ROOT; const uint8_t *const DICT_ROOT;
const int MAX_WORD_LENGTH; const int MAX_WORD_LENGTH;
const int MAX_WORDS; const int MAX_WORDS;
const int TYPED_LETTER_MULTIPLIER; const int TYPED_LETTER_MULTIPLIER;
@ -160,5 +160,4 @@ class UnigramDictionary {
static const digraph_t FRENCH_LIGATURES_DIGRAPHS[]; static const digraph_t FRENCH_LIGATURES_DIGRAPHS[];
}; };
} // namespace latinime } // namespace latinime
#endif // LATINIME_UNIGRAM_DICTIONARY_H #endif // LATINIME_UNIGRAM_DICTIONARY_H

View File

@ -33,7 +33,7 @@ class WordsPriorityQueue {
int mWordLength; int mWordLength;
bool mUsed; bool mUsed;
void setParams(int score, unsigned short* word, int wordLength) { void setParams(int score, unsigned short *word, int wordLength) {
mScore = score; mScore = score;
mWordLength = wordLength; mWordLength = wordLength;
memcpy(mWord, word, sizeof(unsigned short) * wordLength); memcpy(mWord, word, sizeof(unsigned short) * wordLength);
@ -55,8 +55,8 @@ class WordsPriorityQueue {
delete[] mSuggestedWords; delete[] mSuggestedWords;
} }
void push(int score, unsigned short* word, int wordLength) { void push(int score, unsigned short *word, int wordLength) {
SuggestedWord* sw = 0; SuggestedWord *sw = 0;
if (mSuggestions.size() >= MAX_WORDS) { if (mSuggestions.size() >= MAX_WORDS) {
sw = mSuggestions.top(); sw = mSuggestions.top();
const int minScore = sw->mScore; const int minScore = sw->mScore;
@ -86,21 +86,21 @@ class WordsPriorityQueue {
} }
} }
SuggestedWord* top() { SuggestedWord *top() {
if (mSuggestions.empty()) return 0; if (mSuggestions.empty()) return 0;
SuggestedWord* sw = mSuggestions.top(); SuggestedWord *sw = mSuggestions.top();
return sw; return sw;
} }
int outputSuggestions(const unsigned short* before, const int beforeLength, int outputSuggestions(const unsigned short *before, const int beforeLength,
int *frequencies, unsigned short *outputChars) { int *frequencies, unsigned short *outputChars) {
mHighestSuggestedWord = 0; mHighestSuggestedWord = 0;
const unsigned int size = min( const unsigned int size = min(
MAX_WORDS, static_cast<unsigned int>(mSuggestions.size())); MAX_WORDS, static_cast<unsigned int>(mSuggestions.size()));
SuggestedWord* swBuffer[size]; SuggestedWord *swBuffer[size];
int index = size - 1; int index = size - 1;
while (!mSuggestions.empty() && index >= 0) { while (!mSuggestions.empty() && index >= 0) {
SuggestedWord* sw = mSuggestions.top(); SuggestedWord *sw = mSuggestions.top();
if (DEBUG_WORDS_PRIORITY_QUEUE) { if (DEBUG_WORDS_PRIORITY_QUEUE) {
AKLOGI("dump word. %d", sw->mScore); AKLOGI("dump word. %d", sw->mScore);
DUMP_WORD(sw->mWord, sw->mWordLength); DUMP_WORD(sw->mWord, sw->mWordLength);
@ -110,11 +110,11 @@ class WordsPriorityQueue {
--index; --index;
} }
if (size >= 2) { if (size >= 2) {
SuggestedWord* nsMaxSw = 0; SuggestedWord *nsMaxSw = 0;
unsigned int maxIndex = 0; unsigned int maxIndex = 0;
float maxNs = 0; float maxNs = 0;
for (unsigned int i = 0; i < size; ++i) { for (unsigned int i = 0; i < size; ++i) {
SuggestedWord* tempSw = swBuffer[i]; SuggestedWord *tempSw = swBuffer[i];
if (!tempSw) { if (!tempSw) {
continue; continue;
} }
@ -131,13 +131,13 @@ class WordsPriorityQueue {
} }
} }
for (unsigned int i = 0; i < size; ++i) { for (unsigned int i = 0; i < size; ++i) {
SuggestedWord* sw = swBuffer[i]; SuggestedWord *sw = swBuffer[i];
if (!sw) { if (!sw) {
AKLOGE("SuggestedWord is null %d", i); AKLOGE("SuggestedWord is null %d", i);
continue; continue;
} }
const unsigned int wordLength = sw->mWordLength; const unsigned int wordLength = sw->mWordLength;
char* targetAdr = (char*) outputChars + i * MAX_WORD_LENGTH * sizeof(short); char *targetAdr = (char*) outputChars + i * MAX_WORD_LENGTH * sizeof(short);
frequencies[i] = sw->mScore; frequencies[i] = sw->mScore;
memcpy(targetAdr, sw->mWord, (wordLength) * sizeof(short)); memcpy(targetAdr, sw->mWord, (wordLength) * sizeof(short));
if (wordLength < MAX_WORD_LENGTH) { if (wordLength < MAX_WORD_LENGTH) {
@ -155,7 +155,7 @@ class WordsPriorityQueue {
void clear() { void clear() {
mHighestSuggestedWord = 0; mHighestSuggestedWord = 0;
while (!mSuggestions.empty()) { while (!mSuggestions.empty()) {
SuggestedWord* sw = mSuggestions.top(); SuggestedWord *sw = mSuggestions.top();
if (DEBUG_WORDS_PRIORITY_QUEUE) { if (DEBUG_WORDS_PRIORITY_QUEUE) {
AKLOGI("Clear word. %d", sw->mScore); AKLOGI("Clear word. %d", sw->mScore);
DUMP_WORD(sw->mWord, sw->mWordLength); DUMP_WORD(sw->mWord, sw->mWordLength);
@ -172,8 +172,8 @@ class WordsPriorityQueue {
DUMP_WORD(mHighestSuggestedWord->mWord, mHighestSuggestedWord->mWordLength); DUMP_WORD(mHighestSuggestedWord->mWord, mHighestSuggestedWord->mWordLength);
} }
float getHighestNormalizedScore(const unsigned short* before, const int beforeLength, float getHighestNormalizedScore(const unsigned short *before, const int beforeLength,
unsigned short** outWord, int *outScore, int *outLength) { unsigned short **outWord, int *outScore, int *outLength) {
if (!mHighestSuggestedWord) { if (!mHighestSuggestedWord) {
return 0.0; return 0.0;
} }
@ -189,7 +189,7 @@ class WordsPriorityQueue {
} }
}; };
SuggestedWord* getFreeSuggestedWord(int score, unsigned short* word, SuggestedWord *getFreeSuggestedWord(int score, unsigned short *word,
int wordLength) { int wordLength) {
for (unsigned int i = 0; i < MAX_WORD_LENGTH; ++i) { for (unsigned int i = 0; i < MAX_WORD_LENGTH; ++i) {
if (!mSuggestedWords[i].mUsed) { if (!mSuggestedWords[i].mUsed) {
@ -200,10 +200,10 @@ class WordsPriorityQueue {
return 0; return 0;
} }
static float getNormalizedScore(SuggestedWord* sw, const unsigned short* before, static float getNormalizedScore(SuggestedWord *sw, const unsigned short *before,
const int beforeLength, unsigned short** outWord, int *outScore, int *outLength) { const int beforeLength, unsigned short **outWord, int *outScore, int *outLength) {
const int score = sw->mScore; const int score = sw->mScore;
unsigned short* word = sw->mWord; unsigned short *word = sw->mWord;
const int wordLength = sw->mWordLength; const int wordLength = sw->mWordLength;
if (outScore) { if (outScore) {
*outScore = score; *outScore = score;
@ -223,9 +223,8 @@ class WordsPriorityQueue {
Suggestions mSuggestions; Suggestions mSuggestions;
const unsigned int MAX_WORDS; const unsigned int MAX_WORDS;
const unsigned int MAX_WORD_LENGTH; const unsigned int MAX_WORD_LENGTH;
SuggestedWord* mSuggestedWords; SuggestedWord *mSuggestedWords;
SuggestedWord* mHighestSuggestedWord; SuggestedWord *mHighestSuggestedWord;
}; };
} } // namespace latinime
#endif // LATINIME_WORDS_PRIORITY_QUEUE_H #endif // LATINIME_WORDS_PRIORITY_QUEUE_H

View File

@ -44,11 +44,11 @@ class WordsPriorityQueuePool {
} }
} }
WordsPriorityQueue* getMasterQueue() { WordsPriorityQueue *getMasterQueue() {
return mMasterQueue; return mMasterQueue;
} }
WordsPriorityQueue* getSubQueue(const int wordIndex, const int inputWordLength) { WordsPriorityQueue *getSubQueue(const int wordIndex, const int inputWordLength) {
if (wordIndex >= MULTIPLE_WORDS_SUGGESTION_MAX_WORDS) { if (wordIndex >= MULTIPLE_WORDS_SUGGESTION_MAX_WORDS) {
return 0; return 0;
} }
@ -70,7 +70,7 @@ class WordsPriorityQueuePool {
inline void clearSubQueue(const int wordIndex) { inline void clearSubQueue(const int wordIndex) {
for (int i = 0; i < SUB_QUEUE_MAX_COUNT; ++i) { for (int i = 0; i < SUB_QUEUE_MAX_COUNT; ++i) {
WordsPriorityQueue* queue = getSubQueue(wordIndex, i); WordsPriorityQueue *queue = getSubQueue(wordIndex, i);
if (queue) { if (queue) {
queue->clear(); queue->clear();
} }
@ -86,12 +86,11 @@ class WordsPriorityQueuePool {
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(WordsPriorityQueuePool); DISALLOW_IMPLICIT_CONSTRUCTORS(WordsPriorityQueuePool);
WordsPriorityQueue* mMasterQueue; WordsPriorityQueue *mMasterQueue;
WordsPriorityQueue* mSubQueues[SUB_QUEUE_MAX_COUNT * MULTIPLE_WORDS_SUGGESTION_MAX_WORDS]; WordsPriorityQueue *mSubQueues[SUB_QUEUE_MAX_COUNT * MULTIPLE_WORDS_SUGGESTION_MAX_WORDS];
char mMasterQueueBuf[sizeof(WordsPriorityQueue)]; char mMasterQueueBuf[sizeof(WordsPriorityQueue)];
char mSubQueueBuf[MULTIPLE_WORDS_SUGGESTION_MAX_WORDS char mSubQueueBuf[MULTIPLE_WORDS_SUGGESTION_MAX_WORDS
* SUB_QUEUE_MAX_COUNT * sizeof(WordsPriorityQueue)]; * SUB_QUEUE_MAX_COUNT * sizeof(WordsPriorityQueue)];
}; };
} } // namespace latinime
#endif // LATINIME_WORDS_PRIORITY_QUEUE_POOL_H #endif // LATINIME_WORDS_PRIORITY_QUEUE_POOL_H