Make use of the NELEMS and KEYCODE_SPACE macro. Also, remove an unused parameter.
Change-Id: I3c7e6c59990c92b0d5e2fb80493e8673cdd37b09main
parent
60f6120e2b
commit
b02ee3d67a
|
@ -31,7 +31,7 @@ import java.util.Locale;
|
||||||
* Implements a static, compacted, binary dictionary of standard words.
|
* Implements a static, compacted, binary dictionary of standard words.
|
||||||
*/
|
*/
|
||||||
public final class BinaryDictionary extends Dictionary {
|
public final class BinaryDictionary extends Dictionary {
|
||||||
|
private static final String TAG = BinaryDictionary.class.getSimpleName();
|
||||||
public static final String DICTIONARY_PACK_AUTHORITY =
|
public static final String DICTIONARY_PACK_AUTHORITY =
|
||||||
"com.android.inputmethod.latin.dictionarypack";
|
"com.android.inputmethod.latin.dictionarypack";
|
||||||
|
|
||||||
|
@ -45,12 +45,9 @@ public final class BinaryDictionary extends Dictionary {
|
||||||
public static final int MAX_WORDS = 18;
|
public static final int MAX_WORDS = 18;
|
||||||
public static final int MAX_SPACES = 16;
|
public static final int MAX_SPACES = 16;
|
||||||
|
|
||||||
private static final String TAG = BinaryDictionary.class.getSimpleName();
|
|
||||||
private static final int MAX_PREDICTIONS = 60;
|
private static final int MAX_PREDICTIONS = 60;
|
||||||
private static final int MAX_RESULTS = Math.max(MAX_PREDICTIONS, MAX_WORDS);
|
private static final int MAX_RESULTS = Math.max(MAX_PREDICTIONS, MAX_WORDS);
|
||||||
|
|
||||||
private static final int TYPED_LETTER_MULTIPLIER = 2;
|
|
||||||
|
|
||||||
private long mNativeDict;
|
private long mNativeDict;
|
||||||
private final Locale mLocale;
|
private final Locale mLocale;
|
||||||
private final int[] mInputCodePoints = new int[MAX_WORD_LENGTH];
|
private final int[] mInputCodePoints = new int[MAX_WORD_LENGTH];
|
||||||
|
@ -106,8 +103,7 @@ public final class BinaryDictionary extends Dictionary {
|
||||||
}
|
}
|
||||||
|
|
||||||
private native long openNative(String sourceDir, long dictOffset, long dictSize,
|
private native long openNative(String sourceDir, long dictOffset, long dictSize,
|
||||||
int typedLetterMultiplier, int fullWordMultiplier, int maxWordLength, int maxWords,
|
int fullWordMultiplier, int maxWordLength, int maxWords, int maxPredictions);
|
||||||
int maxPredictions);
|
|
||||||
private native void closeNative(long dict);
|
private native void closeNative(long dict);
|
||||||
private native int getFrequencyNative(long dict, int[] word);
|
private native int getFrequencyNative(long dict, int[] word);
|
||||||
private native boolean isValidBigramNative(long dict, int[] word1, int[] word2);
|
private native boolean isValidBigramNative(long dict, int[] word1, int[] word2);
|
||||||
|
@ -121,8 +117,8 @@ public final class BinaryDictionary extends Dictionary {
|
||||||
|
|
||||||
// TODO: Move native dict into session
|
// TODO: Move native dict into session
|
||||||
private final void loadDictionary(String path, long startOffset, long length) {
|
private final void loadDictionary(String path, long startOffset, long length) {
|
||||||
mNativeDict = openNative(path, startOffset, length, TYPED_LETTER_MULTIPLIER,
|
mNativeDict = openNative(path, startOffset, length, FULL_WORD_SCORE_MULTIPLIER,
|
||||||
FULL_WORD_SCORE_MULTIPLIER, MAX_WORD_LENGTH, MAX_WORDS, MAX_PREDICTIONS);
|
MAX_WORD_LENGTH, MAX_WORDS, MAX_PREDICTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#define LOG_TAG "LatinIME: jni: ProximityInfo"
|
#define LOG_TAG "LatinIME: jni: ProximityInfo"
|
||||||
|
|
||||||
#include "com_android_inputmethod_keyboard_ProximityInfo.h"
|
#include "com_android_inputmethod_keyboard_ProximityInfo.h"
|
||||||
|
#include "defines.h"
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
#include "jni_common.h"
|
#include "jni_common.h"
|
||||||
#include "proximity_info.h"
|
#include "proximity_info.h"
|
||||||
|
@ -41,7 +42,7 @@ static void latinime_Keyboard_release(JNIEnv *env, jobject object, jlong proximi
|
||||||
delete pi;
|
delete pi;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JNINativeMethod sKeyboardMethods[] = {
|
static JNINativeMethod sMethods[] = {
|
||||||
{"setProximityInfoNative", "(Ljava/lang/String;IIIIII[II[I[I[I[I[I[F[F[F)J",
|
{"setProximityInfoNative", "(Ljava/lang/String;IIIIII[II[I[I[I[I[I[F[F[F)J",
|
||||||
reinterpret_cast<void *>(latinime_Keyboard_setProximityInfo)},
|
reinterpret_cast<void *>(latinime_Keyboard_setProximityInfo)},
|
||||||
{"releaseProximityInfoNative", "(J)V", reinterpret_cast<void *>(latinime_Keyboard_release)}
|
{"releaseProximityInfoNative", "(J)V", reinterpret_cast<void *>(latinime_Keyboard_release)}
|
||||||
|
@ -49,7 +50,6 @@ static JNINativeMethod sKeyboardMethods[] = {
|
||||||
|
|
||||||
int register_ProximityInfo(JNIEnv *env) {
|
int register_ProximityInfo(JNIEnv *env) {
|
||||||
const char *const kClassPathName = "com/android/inputmethod/keyboard/ProximityInfo";
|
const char *const kClassPathName = "com/android/inputmethod/keyboard/ProximityInfo";
|
||||||
return registerNativeMethods(env, kClassPathName, sKeyboardMethods,
|
return registerNativeMethods(env, kClassPathName, sMethods, NELEMS(sMethods));
|
||||||
sizeof(sKeyboardMethods) / sizeof(sKeyboardMethods[0]));
|
|
||||||
}
|
}
|
||||||
} // namespace latinime
|
} // namespace latinime
|
||||||
|
|
|
@ -44,9 +44,8 @@ class ProximityInfo;
|
||||||
static void releaseDictBuf(const void *dictBuf, const size_t length, const int fd);
|
static void releaseDictBuf(const void *dictBuf, const size_t length, const 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, jint fullWordMultiplier,
|
||||||
jint typedLetterMultiplier, jint fullWordMultiplier, jint maxWordLength, jint maxWords,
|
jint maxWordLength, jint maxWords, jint maxPredictions) {
|
||||||
jint maxPredictions) {
|
|
||||||
PROF_OPEN;
|
PROF_OPEN;
|
||||||
PROF_START(66);
|
PROF_START(66);
|
||||||
const jsize sourceDirUtf8Length = env->GetStringUTFLength(sourceDir);
|
const jsize sourceDirUtf8Length = env->GetStringUTFLength(sourceDir);
|
||||||
|
@ -121,7 +120,7 @@ static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
|
||||||
#endif // USE_MMAP_FOR_DICTIONARY
|
#endif // USE_MMAP_FOR_DICTIONARY
|
||||||
} else {
|
} else {
|
||||||
dictionary = new Dictionary(dictBuf, static_cast<int>(dictSize), fd, adjust,
|
dictionary = new Dictionary(dictBuf, static_cast<int>(dictSize), fd, adjust,
|
||||||
typedLetterMultiplier, fullWordMultiplier, maxWordLength, maxWords, maxPredictions);
|
fullWordMultiplier, maxWordLength, maxWords, maxPredictions);
|
||||||
}
|
}
|
||||||
PROF_END(66);
|
PROF_END(66);
|
||||||
PROF_CLOSE;
|
PROF_CLOSE;
|
||||||
|
@ -277,7 +276,7 @@ static void releaseDictBuf(const void *dictBuf, const size_t length, const int f
|
||||||
}
|
}
|
||||||
|
|
||||||
static JNINativeMethod sMethods[] = {
|
static JNINativeMethod sMethods[] = {
|
||||||
{"openNative", "(Ljava/lang/String;JJIIIII)J",
|
{"openNative", "(Ljava/lang/String;JJIIII)J",
|
||||||
reinterpret_cast<void *>(latinime_BinaryDictionary_open)},
|
reinterpret_cast<void *>(latinime_BinaryDictionary_open)},
|
||||||
{"closeNative", "(J)V", reinterpret_cast<void *>(latinime_BinaryDictionary_close)},
|
{"closeNative", "(J)V", reinterpret_cast<void *>(latinime_BinaryDictionary_close)},
|
||||||
{"getSuggestionsNative", "(JJJ[I[I[I[I[IIIZ[IZ[C[I[I[I)I",
|
{"getSuggestionsNative", "(JJJ[I[I[I[I[IIIZ[IZ[C[I[I[I)I",
|
||||||
|
@ -294,7 +293,6 @@ 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, NELEMS(sMethods));
|
||||||
sizeof(sMethods) / sizeof(sMethods[0]));
|
|
||||||
}
|
}
|
||||||
} // namespace latinime
|
} // namespace latinime
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#define LOG_TAG "LatinIME: jni: Session"
|
#define LOG_TAG "LatinIME: jni: Session"
|
||||||
|
|
||||||
#include "com_android_inputmethod_latin_DicTraverseSession.h"
|
#include "com_android_inputmethod_latin_DicTraverseSession.h"
|
||||||
|
#include "defines.h"
|
||||||
#include "dic_traverse_wrapper.h"
|
#include "dic_traverse_wrapper.h"
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
#include "jni_common.h"
|
#include "jni_common.h"
|
||||||
|
@ -57,7 +58,6 @@ static JNINativeMethod sMethods[] = {
|
||||||
|
|
||||||
int register_DicTraverseSession(JNIEnv *env) {
|
int register_DicTraverseSession(JNIEnv *env) {
|
||||||
const char *const kClassPathName = "com/android/inputmethod/latin/DicTraverseSession";
|
const char *const kClassPathName = "com/android/inputmethod/latin/DicTraverseSession";
|
||||||
return registerNativeMethods(env, kClassPathName, sMethods,
|
return registerNativeMethods(env, kClassPathName, sMethods, NELEMS(sMethods));
|
||||||
sizeof(sMethods) / sizeof(sMethods[0]));
|
|
||||||
}
|
}
|
||||||
} // namespace latinime
|
} // namespace latinime
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "char_utils.h"
|
#include "char_utils.h"
|
||||||
|
#include "defines.h"
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ struct LatinCapitalSmallPair {
|
||||||
//
|
//
|
||||||
// unsigned short c, cc, ccc, ccc2;
|
// unsigned short c, cc, ccc, ccc2;
|
||||||
// for (c = 0; c < 0xFFFF ; c++) {
|
// for (c = 0; c < 0xFFFF ; c++) {
|
||||||
// if (c < sizeof(BASE_CHARS) / sizeof(BASE_CHARS[0])) {
|
// if (c < NELEMS(BASE_CHARS)) {
|
||||||
// cc = BASE_CHARS[c];
|
// cc = BASE_CHARS[c];
|
||||||
// } else {
|
// } else {
|
||||||
// cc = c;
|
// cc = c;
|
||||||
|
@ -894,9 +895,7 @@ static int compare_pair_capital(const void *a, const void *b) {
|
||||||
unsigned short latin_tolower(const unsigned short c) {
|
unsigned short latin_tolower(const unsigned short c) {
|
||||||
struct LatinCapitalSmallPair *p =
|
struct LatinCapitalSmallPair *p =
|
||||||
static_cast<struct LatinCapitalSmallPair *>(bsearch(&c, SORTED_CHAR_MAP,
|
static_cast<struct LatinCapitalSmallPair *>(bsearch(&c, SORTED_CHAR_MAP,
|
||||||
sizeof(SORTED_CHAR_MAP) / sizeof(SORTED_CHAR_MAP[0]),
|
NELEMS(SORTED_CHAR_MAP), sizeof(SORTED_CHAR_MAP[0]), compare_pair_capital));
|
||||||
sizeof(SORTED_CHAR_MAP[0]),
|
|
||||||
compare_pair_capital));
|
|
||||||
return p ? p->small : c;
|
return p ? p->small : c;
|
||||||
}
|
}
|
||||||
} // namespace latinime
|
} // namespace latinime
|
||||||
|
|
|
@ -1118,7 +1118,7 @@ float Correction::RankingAlgorithm::calcNormalizedScore(const unsigned short *be
|
||||||
const int distance = editDistance(before, beforeLength, after, afterLength);
|
const int distance = editDistance(before, beforeLength, after, afterLength);
|
||||||
int spaceCount = 0;
|
int spaceCount = 0;
|
||||||
for (int i = 0; i < afterLength; ++i) {
|
for (int i = 0; i < afterLength; ++i) {
|
||||||
if (after[i] == CODE_SPACE) {
|
if (after[i] == KEYCODE_SPACE) {
|
||||||
++spaceCount;
|
++spaceCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,6 @@ class Correction {
|
||||||
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 MAX_INITIAL_SCORE = 255;
|
static const int MAX_INITIAL_SCORE = 255;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -344,8 +344,8 @@ static inline void prof_out(void) {
|
||||||
#define MULTIPLE_WORDS_DEMOTION_RATE 80
|
#define MULTIPLE_WORDS_DEMOTION_RATE 80
|
||||||
#define MIN_INPUT_LENGTH_FOR_THREE_OR_MORE_WORDS_CORRECTION 6
|
#define MIN_INPUT_LENGTH_FOR_THREE_OR_MORE_WORDS_CORRECTION 6
|
||||||
|
|
||||||
#define TWO_WORDS_CORRECTION_WITH_OTHER_ERROR_THRESHOLD 0.35
|
#define TWO_WORDS_CORRECTION_WITH_OTHER_ERROR_THRESHOLD 0.35f
|
||||||
#define START_TWO_WORDS_CORRECTION_THRESHOLD 0.185
|
#define START_TWO_WORDS_CORRECTION_THRESHOLD 0.185f
|
||||||
/* heuristic... This should be changed if we change the unit of the frequency. */
|
/* heuristic... This should be changed if we change the unit of the frequency. */
|
||||||
#define SUPPRESS_SHORT_MULTIPLE_WORDS_THRESHOLD_FREQ (MAX_FREQ * 58 / 100)
|
#define SUPPRESS_SHORT_MULTIPLE_WORDS_THRESHOLD_FREQ (MAX_FREQ * 58 / 100)
|
||||||
|
|
||||||
|
@ -392,6 +392,8 @@ static inline void prof_out(void) {
|
||||||
template<typename T> inline T min(T a, T b) { return a < b ? a : b; }
|
template<typename T> inline T min(T a, T b) { return a < b ? a : b; }
|
||||||
template<typename T> inline T max(T a, T b) { return a > b ? a : b; }
|
template<typename T> inline T max(T a, T b) { return a > b ? a : b; }
|
||||||
|
|
||||||
|
#define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
|
|
||||||
// The ratio of neutral area radius to sweet spot radius.
|
// The ratio of neutral area radius to sweet spot radius.
|
||||||
#define NEUTRAL_AREA_RADIUS_RATIO 1.3f
|
#define NEUTRAL_AREA_RADIUS_RATIO 1.3f
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,12 @@ namespace latinime {
|
||||||
|
|
||||||
// TODO: Change the type of all keyCodes to uint32_t
|
// TODO: Change the type of all keyCodes to uint32_t
|
||||||
Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
|
Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
|
||||||
int typedLetterMultiplier, int fullWordMultiplier, int maxWordLength, int maxWords,
|
int fullWordMultiplier, int maxWordLength, int maxWords, int maxPredictions)
|
||||||
int maxPredictions)
|
|
||||||
: mDict(static_cast<unsigned char *>(dict)),
|
: mDict(static_cast<unsigned char *>(dict)),
|
||||||
mOffsetDict((static_cast<unsigned char *>(dict)) + BinaryFormat::getHeaderSize(mDict)),
|
mOffsetDict((static_cast<unsigned char *>(dict)) + BinaryFormat::getHeaderSize(mDict)),
|
||||||
mDictSize(dictSize), mMmapFd(mmapFd), mDictBufAdjust(dictBufAdjust),
|
mDictSize(dictSize), mMmapFd(mmapFd), mDictBufAdjust(dictBufAdjust),
|
||||||
mUnigramDictionary(new UnigramDictionary(mOffsetDict, typedLetterMultiplier,
|
mUnigramDictionary(new UnigramDictionary(mOffsetDict, fullWordMultiplier, maxWordLength,
|
||||||
fullWordMultiplier, maxWordLength, maxWords, BinaryFormat::getFlags(mDict))),
|
maxWords, BinaryFormat::getFlags(mDict))),
|
||||||
mBigramDictionary(new BigramDictionary(mOffsetDict, maxWordLength, maxPredictions)),
|
mBigramDictionary(new BigramDictionary(mOffsetDict, maxWordLength, maxPredictions)),
|
||||||
mGestureDecoder(new GestureDecoderWrapper(maxWordLength, maxWords)) {
|
mGestureDecoder(new GestureDecoderWrapper(maxWordLength, maxWords)) {
|
||||||
if (DEBUG_DICT) {
|
if (DEBUG_DICT) {
|
||||||
|
|
|
@ -41,8 +41,8 @@ class Dictionary {
|
||||||
const static int KIND_SHORTCUT = 7; // A shortcut
|
const static int KIND_SHORTCUT = 7; // A shortcut
|
||||||
const static int KIND_PREDICTION = 8; // A prediction (== a suggestion with no input)
|
const static int KIND_PREDICTION = 8; // A prediction (== a suggestion with no input)
|
||||||
|
|
||||||
Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int typedLetterMultipler,
|
Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int fullWordMultiplier,
|
||||||
int fullWordMultiplier, int maxWordLength, int maxWords, int maxPredictions);
|
int maxWordLength, int maxWords, int maxPredictions);
|
||||||
|
|
||||||
int getSuggestions(ProximityInfo *proximityInfo, void *traverseSession, int *xcoordinates,
|
int getSuggestions(ProximityInfo *proximityInfo, void *traverseSession, int *xcoordinates,
|
||||||
int *ycoordinates, int *times, int *pointerIds, int *codes, int codesSize,
|
int *ycoordinates, int *times, int *pointerIds, int *codes, int codesSize,
|
||||||
|
|
|
@ -518,7 +518,7 @@ float ProximityInfoState::getPointToKeyLength(const int inputIndex, const int co
|
||||||
}
|
}
|
||||||
|
|
||||||
int ProximityInfoState::getSpaceY() const {
|
int ProximityInfoState::getSpaceY() const {
|
||||||
const int keyId = mProximityInfo->getKeyIndexOf(' ');
|
const int keyId = mProximityInfo->getKeyIndexOf(KEYCODE_SPACE);
|
||||||
return mProximityInfo->getKeyCenterYOfKeyIdG(keyId);
|
return mProximityInfo->getKeyCenterYOfKeyIdG(keyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,13 +41,11 @@ 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 fullWordMultiplier,
|
||||||
int fullWordMultiplier, int maxWordLength, int maxWords, const unsigned int flags)
|
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),
|
FULL_WORD_MULTIPLIER(fullWordMultiplier), // TODO : remove this variable.
|
||||||
// TODO : remove this variable.
|
ROOT_POS(0), BYTES_IN_ONE_CHAR(sizeof(int)),
|
||||||
ROOT_POS(0),
|
|
||||||
BYTES_IN_ONE_CHAR(sizeof(int)),
|
|
||||||
MAX_DIGRAPH_SEARCH_DEPTH(DEFAULT_MAX_DIGRAPH_SEARCH_DEPTH), FLAGS(flags) {
|
MAX_DIGRAPH_SEARCH_DEPTH(DEFAULT_MAX_DIGRAPH_SEARCH_DEPTH), FLAGS(flags) {
|
||||||
if (DEBUG_DICT) {
|
if (DEBUG_DICT) {
|
||||||
AKLOGI("UnigramDictionary - constructor");
|
AKLOGI("UnigramDictionary - constructor");
|
||||||
|
@ -188,8 +186,7 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo, const int *x
|
||||||
getWordWithDigraphSuggestionsRec(proximityInfo, xcoordinates, ycoordinates, codesBuffer,
|
getWordWithDigraphSuggestionsRec(proximityInfo, xcoordinates, ycoordinates, codesBuffer,
|
||||||
xCoordinatesBuffer, yCoordinatesBuffer, codesSize, bigramMap, bigramFilter,
|
xCoordinatesBuffer, yCoordinatesBuffer, codesSize, bigramMap, bigramFilter,
|
||||||
useFullEditDistance, codes, codesSize, 0, codesBuffer, &masterCorrection,
|
useFullEditDistance, codes, codesSize, 0, codesBuffer, &masterCorrection,
|
||||||
&queuePool, GERMAN_UMLAUT_DIGRAPHS,
|
&queuePool, GERMAN_UMLAUT_DIGRAPHS, NELEMS(GERMAN_UMLAUT_DIGRAPHS));
|
||||||
sizeof(GERMAN_UMLAUT_DIGRAPHS) / sizeof(GERMAN_UMLAUT_DIGRAPHS[0]));
|
|
||||||
} else if (BinaryFormat::REQUIRES_FRENCH_LIGATURES_PROCESSING & FLAGS) {
|
} else if (BinaryFormat::REQUIRES_FRENCH_LIGATURES_PROCESSING & FLAGS) {
|
||||||
int codesBuffer[getCodesBufferSize(codes, codesSize)];
|
int codesBuffer[getCodesBufferSize(codes, codesSize)];
|
||||||
int xCoordinatesBuffer[codesSize];
|
int xCoordinatesBuffer[codesSize];
|
||||||
|
@ -197,8 +194,7 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo, const int *x
|
||||||
getWordWithDigraphSuggestionsRec(proximityInfo, xcoordinates, ycoordinates, codesBuffer,
|
getWordWithDigraphSuggestionsRec(proximityInfo, xcoordinates, ycoordinates, codesBuffer,
|
||||||
xCoordinatesBuffer, yCoordinatesBuffer, codesSize, bigramMap, bigramFilter,
|
xCoordinatesBuffer, yCoordinatesBuffer, codesSize, bigramMap, bigramFilter,
|
||||||
useFullEditDistance, codes, codesSize, 0, codesBuffer, &masterCorrection,
|
useFullEditDistance, codes, codesSize, 0, codesBuffer, &masterCorrection,
|
||||||
&queuePool, FRENCH_LIGATURES_DIGRAPHS,
|
&queuePool, FRENCH_LIGATURES_DIGRAPHS, NELEMS(FRENCH_LIGATURES_DIGRAPHS));
|
||||||
sizeof(FRENCH_LIGATURES_DIGRAPHS) / sizeof(FRENCH_LIGATURES_DIGRAPHS[0]));
|
|
||||||
} else { // Normal processing
|
} else { // Normal processing
|
||||||
getWordSuggestions(proximityInfo, xcoordinates, ycoordinates, codes, codesSize,
|
getWordSuggestions(proximityInfo, xcoordinates, ycoordinates, codes, codesSize,
|
||||||
bigramMap, bigramFilter, useFullEditDistance, &masterCorrection, &queuePool);
|
bigramMap, bigramFilter, useFullEditDistance, &masterCorrection, &queuePool);
|
||||||
|
@ -314,8 +310,6 @@ void UnigramDictionary::initSuggestions(ProximityInfo *proximityInfo, const int
|
||||||
correction->initCorrection(proximityInfo, inputSize, maxDepth);
|
correction->initCorrection(proximityInfo, inputSize, maxDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char SPACE = ' ';
|
|
||||||
|
|
||||||
void UnigramDictionary::getOneWordSuggestions(ProximityInfo *proximityInfo,
|
void UnigramDictionary::getOneWordSuggestions(ProximityInfo *proximityInfo,
|
||||||
const int *xcoordinates, const int *ycoordinates, const int *codes,
|
const int *xcoordinates, const int *ycoordinates, const int *codes,
|
||||||
const std::map<int, int> *bigramMap, const uint8_t *bigramFilter,
|
const std::map<int, int> *bigramMap, const uint8_t *bigramFilter,
|
||||||
|
@ -570,7 +564,7 @@ int UnigramDictionary::getSubStringSuggestion(
|
||||||
if (outputWordStartPos + nextWordLength >= MAX_WORD_LENGTH) {
|
if (outputWordStartPos + nextWordLength >= MAX_WORD_LENGTH) {
|
||||||
return FLAG_MULTIPLE_SUGGEST_SKIP;
|
return FLAG_MULTIPLE_SUGGEST_SKIP;
|
||||||
}
|
}
|
||||||
outputWord[tempOutputWordLength] = SPACE;
|
outputWord[tempOutputWordLength] = KEYCODE_SPACE;
|
||||||
if (outputWordLength) {
|
if (outputWordLength) {
|
||||||
++*outputWordLength;
|
++*outputWordLength;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@ 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 fullWordMultiplier, int maxWordLength,
|
||||||
int fullWordMultiplier, int maxWordLength, int maxWords, const unsigned int flags);
|
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(ProximityInfo *proximityInfo, const int *xcoordinates,
|
int getSuggestions(ProximityInfo *proximityInfo, const int *xcoordinates,
|
||||||
|
@ -115,7 +115,6 @@ class UnigramDictionary {
|
||||||
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 FULL_WORD_MULTIPLIER;
|
const int FULL_WORD_MULTIPLIER;
|
||||||
const int ROOT_POS;
|
const int ROOT_POS;
|
||||||
const unsigned int BYTES_IN_ONE_CHAR;
|
const unsigned int BYTES_IN_ONE_CHAR;
|
||||||
|
|
Loading…
Reference in New Issue