Loading native/jni/src/binary_format.h +7 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,8 @@ class BinaryFormat { // Mask for attribute frequency, stored on 4 bits inside the flags byte. static const int MASK_ATTRIBUTE_FREQUENCY = 0x0F; // The numeric value of the shortcut frequency that means 'whitelist'. static const int WHITELIST_SHORTCUT_FREQUENCY = 15; // Mask and flags for attribute address type selection. static const int MASK_ATTRIBUTE_ADDRESS_TYPE = 0x30; Loading Loading @@ -99,6 +101,7 @@ class BinaryFormat { static bool hasChildrenInFlags(const uint8_t flags); static int getAttributeAddressAndForwardPointer(const uint8_t *const dict, const uint8_t flags, int *pos); static int getAttributeFrequencyFromFlags(const int flags); static int getTerminalPosition(const uint8_t *const root, const int32_t *const inWord, const int length, const bool forceLowerCaseSearch); static int getWordAtAddress(const uint8_t *const root, const int address, const int maxDepth, Loading Loading @@ -340,6 +343,10 @@ inline int BinaryFormat::getAttributeAddressAndForwardPointer(const uint8_t *con } } inline int BinaryFormat::getAttributeFrequencyFromFlags(const int flags) { return flags & MASK_ATTRIBUTE_FREQUENCY; } // 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. inline int BinaryFormat::getTerminalPosition(const uint8_t *const root, Loading native/jni/src/correction.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,10 @@ void Correction::checkState() { } } bool Correction::sameAsTyped() { return mProximityInfoState.sameAsTyped(mWord, mOutputIndex); } int Correction::getFreqForSplitMultipleWords(const int *freqArray, const int *wordLengthArray, const int wordCount, const bool isSpaceProximity, const unsigned short *word) { return Correction::RankingAlgorithm::calcFreqForSplitMultipleWords(freqArray, wordLengthArray, Loading native/jni/src/correction.h +1 −0 Original line number Diff line number Diff line Loading @@ -105,6 +105,7 @@ class Correction { const int spaceProximityPos, const int missingSpacePos, const bool useFullEditDistance, const bool doAutoCompletion, const int maxErrors); void checkState(); bool sameAsTyped(); bool initProcessState(const int index); int getInputIndex(); Loading native/jni/src/proximity_info_state.h +15 −15 Original line number Diff line number Diff line Loading @@ -160,6 +160,21 @@ class ProximityInfoState { return mTouchPositionCorrectionEnabled; } inline bool sameAsTyped(const unsigned short *word, int length) const { if (length != mInputLength) { return false; } const int *inputCodes = mInputCodes; while (length--) { if (static_cast<unsigned int>(*inputCodes) != static_cast<unsigned int>(*word)) { return false; } inputCodes += MAX_PROXIMITY_CHARS_SIZE_INTERNAL; word++; } return true; } private: DISALLOW_COPY_AND_ASSIGN(ProximityInfoState); ///////////////////////////////////////// Loading @@ -179,21 +194,6 @@ class ProximityInfoState { return mInputXCoordinates && mInputYCoordinates; } bool sameAsTyped(const unsigned short *word, int length) const { if (length != mInputLength) { return false; } const int *inputCodes = mInputCodes; while (length--) { if ((unsigned int) *inputCodes != (unsigned int) *word) { return false; } inputCodes += MAX_PROXIMITY_CHARS_SIZE_INTERNAL; word++; } return true; } // const const ProximityInfo *mProximityInfo; bool mHasTouchPositionCorrectionData; Loading native/jni/src/terminal_attributes.h +2 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ class TerminalAttributes { // Gets the shortcut target itself as a uint16_t string. For parameters and return value // see BinaryFormat::getWordAtAddress. // 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, int *outFreq) { const int shortcutFlags = BinaryFormat::getFlagsAndForwardPointer(mDict, &mPos); mHasNextShortcutTarget = 0 != (shortcutFlags & BinaryFormat::FLAG_ATTRIBUTE_HAS_NEXT); Loading @@ -56,6 +56,7 @@ class TerminalAttributes { if (NOT_A_CHARACTER == charCode) break; outWord[i] = (uint16_t)charCode; } *outFreq = BinaryFormat::getAttributeFrequencyFromFlags(shortcutFlags); mPos += BinaryFormat::CHARACTER_ARRAY_TERMINATOR_SIZE; return i; } Loading Loading
native/jni/src/binary_format.h +7 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,8 @@ class BinaryFormat { // Mask for attribute frequency, stored on 4 bits inside the flags byte. static const int MASK_ATTRIBUTE_FREQUENCY = 0x0F; // The numeric value of the shortcut frequency that means 'whitelist'. static const int WHITELIST_SHORTCUT_FREQUENCY = 15; // Mask and flags for attribute address type selection. static const int MASK_ATTRIBUTE_ADDRESS_TYPE = 0x30; Loading Loading @@ -99,6 +101,7 @@ class BinaryFormat { static bool hasChildrenInFlags(const uint8_t flags); static int getAttributeAddressAndForwardPointer(const uint8_t *const dict, const uint8_t flags, int *pos); static int getAttributeFrequencyFromFlags(const int flags); static int getTerminalPosition(const uint8_t *const root, const int32_t *const inWord, const int length, const bool forceLowerCaseSearch); static int getWordAtAddress(const uint8_t *const root, const int address, const int maxDepth, Loading Loading @@ -340,6 +343,10 @@ inline int BinaryFormat::getAttributeAddressAndForwardPointer(const uint8_t *con } } inline int BinaryFormat::getAttributeFrequencyFromFlags(const int flags) { return flags & MASK_ATTRIBUTE_FREQUENCY; } // 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. inline int BinaryFormat::getTerminalPosition(const uint8_t *const root, Loading
native/jni/src/correction.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,10 @@ void Correction::checkState() { } } bool Correction::sameAsTyped() { return mProximityInfoState.sameAsTyped(mWord, mOutputIndex); } int Correction::getFreqForSplitMultipleWords(const int *freqArray, const int *wordLengthArray, const int wordCount, const bool isSpaceProximity, const unsigned short *word) { return Correction::RankingAlgorithm::calcFreqForSplitMultipleWords(freqArray, wordLengthArray, Loading
native/jni/src/correction.h +1 −0 Original line number Diff line number Diff line Loading @@ -105,6 +105,7 @@ class Correction { const int spaceProximityPos, const int missingSpacePos, const bool useFullEditDistance, const bool doAutoCompletion, const int maxErrors); void checkState(); bool sameAsTyped(); bool initProcessState(const int index); int getInputIndex(); Loading
native/jni/src/proximity_info_state.h +15 −15 Original line number Diff line number Diff line Loading @@ -160,6 +160,21 @@ class ProximityInfoState { return mTouchPositionCorrectionEnabled; } inline bool sameAsTyped(const unsigned short *word, int length) const { if (length != mInputLength) { return false; } const int *inputCodes = mInputCodes; while (length--) { if (static_cast<unsigned int>(*inputCodes) != static_cast<unsigned int>(*word)) { return false; } inputCodes += MAX_PROXIMITY_CHARS_SIZE_INTERNAL; word++; } return true; } private: DISALLOW_COPY_AND_ASSIGN(ProximityInfoState); ///////////////////////////////////////// Loading @@ -179,21 +194,6 @@ class ProximityInfoState { return mInputXCoordinates && mInputYCoordinates; } bool sameAsTyped(const unsigned short *word, int length) const { if (length != mInputLength) { return false; } const int *inputCodes = mInputCodes; while (length--) { if ((unsigned int) *inputCodes != (unsigned int) *word) { return false; } inputCodes += MAX_PROXIMITY_CHARS_SIZE_INTERNAL; word++; } return true; } // const const ProximityInfo *mProximityInfo; bool mHasTouchPositionCorrectionData; Loading
native/jni/src/terminal_attributes.h +2 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ class TerminalAttributes { // Gets the shortcut target itself as a uint16_t string. For parameters and return value // see BinaryFormat::getWordAtAddress. // 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, int *outFreq) { const int shortcutFlags = BinaryFormat::getFlagsAndForwardPointer(mDict, &mPos); mHasNextShortcutTarget = 0 != (shortcutFlags & BinaryFormat::FLAG_ATTRIBUTE_HAS_NEXT); Loading @@ -56,6 +56,7 @@ class TerminalAttributes { if (NOT_A_CHARACTER == charCode) break; outWord[i] = (uint16_t)charCode; } *outFreq = BinaryFormat::getAttributeFrequencyFromFlags(shortcutFlags); mPos += BinaryFormat::CHARACTER_ARRAY_TERMINATOR_SIZE; return i; } Loading