diff --git a/native/jni/src/correction.cpp b/native/jni/src/correction.cpp index 15a71312225de48abd2c9fa17dc214c9467dc3d8..49e3e3c8cf61ba7c37de7f0200fcdb05432ad2ae 100644 --- a/native/jni/src/correction.cpp +++ b/native/jni/src/correction.cpp @@ -631,7 +631,7 @@ Correction::CorrectionType Correction::processCharAndCalcState( inline static int getQuoteCount(const unsigned short *word, const int length) { int quoteCount = 0; for (int i = 0; i < length; ++i) { - if (word[i] == '\'') { + if (word[i] == SINGLE_QUOTE) { ++quoteCount; } } diff --git a/native/jni/src/proximity_info.h b/native/jni/src/proximity_info.h index 2f258ef86a3e56931564255b07e7f1ea98171e1c..0d8c6a3ca00f3c97cdcb943c870910ca73dc94be 100644 --- a/native/jni/src/proximity_info.h +++ b/native/jni/src/proximity_info.h @@ -27,6 +27,11 @@ namespace latinime { class Correction; +inline bool isSkippableChar(const uint16_t character) { + // TODO: Do not hardcode here + return character == '\'' || character == '-'; +} + class ProximityInfo { public: ProximityInfo(JNIEnv *env, const jstring localeJStr, const int maxProximityCharsSize, diff --git a/native/jni/src/proximity_info_state.cpp b/native/jni/src/proximity_info_state.cpp index 7e917a929b80a860d7cfcfae9cc4fe55cdb69083..3edd9b391ef0ac339ecf2c7cfd055b20d27eb7c7 100644 --- a/native/jni/src/proximity_info_state.cpp +++ b/native/jni/src/proximity_info_state.cpp @@ -469,9 +469,7 @@ float ProximityInfoState::getPointToKeyLength(const int inputIndex, const int co const int index = inputIndex * mProximityInfo->getKeyCount() + keyId; return min(mDistanceCache[index] * scale, mMaxPointToKeyLength); } - // TODO: Do not hardcode here - // No penalty to ' and - - if (codePoint == '\'' || codePoint == '-') { + if (isSkippableChar(codePoint)) { return 0; } // If the char is not a key on the keyboard then return the max length. diff --git a/native/jni/src/unigram_dictionary.cpp b/native/jni/src/unigram_dictionary.cpp index 6eaff48dfbf0bd1e7abd26a2bdf967e68c7bd135..49d044fbcc130935b1745fbe3e593f2e84019a64 100644 --- a/native/jni/src/unigram_dictionary.cpp +++ b/native/jni/src/unigram_dictionary.cpp @@ -314,7 +314,6 @@ void UnigramDictionary::initSuggestions(ProximityInfo *proximityInfo, const int correction->initCorrection(proximityInfo, inputSize, maxDepth); } -static const char QUOTE = '\''; static const char SPACE = ' '; void UnigramDictionary::getOneWordSuggestions(ProximityInfo *proximityInfo,