Loading native/jni/src/defines.h +1 −0 Original line number Diff line number Diff line Loading @@ -270,6 +270,7 @@ static inline void prof_out(void) { #define NOT_A_COORDINATE (-1) #define NOT_AN_INDEX (-1) #define NOT_A_PROBABILITY (-1) #define NOT_A_DICT_POS (S_INT_MIN) #define KEYCODE_SPACE ' ' #define KEYCODE_SINGLE_QUOTE '\'' Loading native/jni/src/suggest/core/dicnode/dic_node.h +4 −7 Original line number Diff line number Diff line Loading @@ -97,7 +97,6 @@ class DicNode { DicNode &operator=(const DicNode &dicNode); virtual ~DicNode() {} // TODO: minimize arguments by looking binary_format // Init for copy void initByCopy(const DicNode *dicNode) { mIsUsed = true; Loading @@ -107,13 +106,12 @@ class DicNode { PROF_NODE_COPY(&dicNode->mProfiler, mProfiler); } // TODO: minimize arguments by looking binary_format // Init for root with prevWordNodePos which is used for bigram void initAsRoot(const int pos, const int childrenPos, const int prevWordNodePos) { void initAsRoot(const int rootGroupPos, const int prevWordNodePos) { mIsUsed = true; mIsCachedForNextSuggestion = false; mDicNodeProperties.init( pos, 0 /* flags */, childrenPos, 0 /* attributesPos */, NOT_A_DICT_POS, 0 /* flags */, rootGroupPos, NOT_A_DICT_POS /* attributesPos */, NOT_A_CODE_POINT /* nodeCodePoint */, NOT_A_PROBABILITY /* probability */, false /* isTerminal */, true /* hasChildren */, 0 /* depth */, 0 /* terminalDepth */); Loading @@ -130,13 +128,12 @@ class DicNode { PROF_NODE_COPY(&parentNode->mProfiler, mProfiler); } // TODO: minimize arguments by looking binary_format // Init for root with previous word void initAsRootWithPreviousWord(DicNode *dicNode, const int pos, const int childrenPos) { void initAsRootWithPreviousWord(DicNode *dicNode, const int rootGroupPos) { mIsUsed = true; mIsCachedForNextSuggestion = dicNode->mIsCachedForNextSuggestion; mDicNodeProperties.init( pos, 0 /* flags */, childrenPos, 0 /* attributesPos */, NOT_A_DICT_POS, 0 /* flags */, rootGroupPos, NOT_A_DICT_POS /* attributesPos */, NOT_A_CODE_POINT /* nodeCodePoint */, NOT_A_PROBABILITY /* probability */, false /* isTerminal */, true /* hasChildren */, 0 /* depth */, 0 /* terminalDepth */); Loading native/jni/src/suggest/core/dicnode/dic_node_utils.cpp +8 −9 Original line number Diff line number Diff line Loading @@ -36,17 +36,14 @@ namespace latinime { /* static */ void DicNodeUtils::initAsRoot(const BinaryDictionaryInfo *const binaryDictionaryInfo, const int prevWordNodePos, DicNode *const newRootNode) { const int rootPos = binaryDictionaryInfo->getRootPosition(); const int childrenPos = rootPos; newRootNode->initAsRoot(rootPos, childrenPos, prevWordNodePos); newRootNode->initAsRoot(binaryDictionaryInfo->getRootPosition(), prevWordNodePos); } /*static */ void DicNodeUtils::initAsRootWithPreviousWord( const BinaryDictionaryInfo *const binaryDictionaryInfo, DicNode *const prevWordLastNode, DicNode *const newRootNode) { const int rootPos = binaryDictionaryInfo->getRootPosition(); const int childrenPos = rootPos; newRootNode->initAsRootWithPreviousWord(prevWordLastNode, rootPos, childrenPos); newRootNode->initAsRootWithPreviousWord( prevWordLastNode, binaryDictionaryInfo->getRootPosition()); } /* static */ void DicNodeUtils::initByCopy(DicNode *srcNode, DicNode *destNode) { Loading Loading @@ -80,6 +77,7 @@ namespace latinime { const bool hasMultipleChars = (0 != (BinaryFormat::FLAG_HAS_MULTIPLE_CHARS & flags)); const bool isTerminal = (0 != (BinaryFormat::FLAG_IS_TERMINAL & flags)); const bool hasChildren = BinaryFormat::hasChildrenInFlags(flags); const bool hasShortcuts = (0 != (BinaryFormat::FLAG_HAS_SHORTCUT_TARGETS & flags)); int codePoint = BinaryFormat::getCodePointAndForwardPointer( binaryDictionaryInfo->getDictRoot(), &pos); Loading @@ -101,11 +99,12 @@ namespace latinime { } while (NOT_A_CODE_POINT != codePoint); const int probability = isTerminal ? BinaryFormat::readProbabilityWithoutMovingPointer( binaryDictionaryInfo->getDictRoot(), pos) : -1; binaryDictionaryInfo->getDictRoot(), pos) : NOT_A_PROBABILITY; pos = BinaryFormat::skipProbability(flags, pos); int childrenPos = hasChildren ? BinaryFormat::readChildrenPosition( binaryDictionaryInfo->getDictRoot(), flags, pos) : 0; const int attributesPos = BinaryFormat::skipChildrenPosition(flags, pos); binaryDictionaryInfo->getDictRoot(), flags, pos) : NOT_A_DICT_POS; const int attributesPos = hasShortcuts ? BinaryFormat::skipChildrenPosition(flags, pos) : NOT_A_DICT_POS; const int siblingPos = BinaryFormat::skipChildrenPosAndAttributes( binaryDictionaryInfo->getDictRoot(), flags, pos); Loading Loading
native/jni/src/defines.h +1 −0 Original line number Diff line number Diff line Loading @@ -270,6 +270,7 @@ static inline void prof_out(void) { #define NOT_A_COORDINATE (-1) #define NOT_AN_INDEX (-1) #define NOT_A_PROBABILITY (-1) #define NOT_A_DICT_POS (S_INT_MIN) #define KEYCODE_SPACE ' ' #define KEYCODE_SINGLE_QUOTE '\'' Loading
native/jni/src/suggest/core/dicnode/dic_node.h +4 −7 Original line number Diff line number Diff line Loading @@ -97,7 +97,6 @@ class DicNode { DicNode &operator=(const DicNode &dicNode); virtual ~DicNode() {} // TODO: minimize arguments by looking binary_format // Init for copy void initByCopy(const DicNode *dicNode) { mIsUsed = true; Loading @@ -107,13 +106,12 @@ class DicNode { PROF_NODE_COPY(&dicNode->mProfiler, mProfiler); } // TODO: minimize arguments by looking binary_format // Init for root with prevWordNodePos which is used for bigram void initAsRoot(const int pos, const int childrenPos, const int prevWordNodePos) { void initAsRoot(const int rootGroupPos, const int prevWordNodePos) { mIsUsed = true; mIsCachedForNextSuggestion = false; mDicNodeProperties.init( pos, 0 /* flags */, childrenPos, 0 /* attributesPos */, NOT_A_DICT_POS, 0 /* flags */, rootGroupPos, NOT_A_DICT_POS /* attributesPos */, NOT_A_CODE_POINT /* nodeCodePoint */, NOT_A_PROBABILITY /* probability */, false /* isTerminal */, true /* hasChildren */, 0 /* depth */, 0 /* terminalDepth */); Loading @@ -130,13 +128,12 @@ class DicNode { PROF_NODE_COPY(&parentNode->mProfiler, mProfiler); } // TODO: minimize arguments by looking binary_format // Init for root with previous word void initAsRootWithPreviousWord(DicNode *dicNode, const int pos, const int childrenPos) { void initAsRootWithPreviousWord(DicNode *dicNode, const int rootGroupPos) { mIsUsed = true; mIsCachedForNextSuggestion = dicNode->mIsCachedForNextSuggestion; mDicNodeProperties.init( pos, 0 /* flags */, childrenPos, 0 /* attributesPos */, NOT_A_DICT_POS, 0 /* flags */, rootGroupPos, NOT_A_DICT_POS /* attributesPos */, NOT_A_CODE_POINT /* nodeCodePoint */, NOT_A_PROBABILITY /* probability */, false /* isTerminal */, true /* hasChildren */, 0 /* depth */, 0 /* terminalDepth */); Loading
native/jni/src/suggest/core/dicnode/dic_node_utils.cpp +8 −9 Original line number Diff line number Diff line Loading @@ -36,17 +36,14 @@ namespace latinime { /* static */ void DicNodeUtils::initAsRoot(const BinaryDictionaryInfo *const binaryDictionaryInfo, const int prevWordNodePos, DicNode *const newRootNode) { const int rootPos = binaryDictionaryInfo->getRootPosition(); const int childrenPos = rootPos; newRootNode->initAsRoot(rootPos, childrenPos, prevWordNodePos); newRootNode->initAsRoot(binaryDictionaryInfo->getRootPosition(), prevWordNodePos); } /*static */ void DicNodeUtils::initAsRootWithPreviousWord( const BinaryDictionaryInfo *const binaryDictionaryInfo, DicNode *const prevWordLastNode, DicNode *const newRootNode) { const int rootPos = binaryDictionaryInfo->getRootPosition(); const int childrenPos = rootPos; newRootNode->initAsRootWithPreviousWord(prevWordLastNode, rootPos, childrenPos); newRootNode->initAsRootWithPreviousWord( prevWordLastNode, binaryDictionaryInfo->getRootPosition()); } /* static */ void DicNodeUtils::initByCopy(DicNode *srcNode, DicNode *destNode) { Loading Loading @@ -80,6 +77,7 @@ namespace latinime { const bool hasMultipleChars = (0 != (BinaryFormat::FLAG_HAS_MULTIPLE_CHARS & flags)); const bool isTerminal = (0 != (BinaryFormat::FLAG_IS_TERMINAL & flags)); const bool hasChildren = BinaryFormat::hasChildrenInFlags(flags); const bool hasShortcuts = (0 != (BinaryFormat::FLAG_HAS_SHORTCUT_TARGETS & flags)); int codePoint = BinaryFormat::getCodePointAndForwardPointer( binaryDictionaryInfo->getDictRoot(), &pos); Loading @@ -101,11 +99,12 @@ namespace latinime { } while (NOT_A_CODE_POINT != codePoint); const int probability = isTerminal ? BinaryFormat::readProbabilityWithoutMovingPointer( binaryDictionaryInfo->getDictRoot(), pos) : -1; binaryDictionaryInfo->getDictRoot(), pos) : NOT_A_PROBABILITY; pos = BinaryFormat::skipProbability(flags, pos); int childrenPos = hasChildren ? BinaryFormat::readChildrenPosition( binaryDictionaryInfo->getDictRoot(), flags, pos) : 0; const int attributesPos = BinaryFormat::skipChildrenPosition(flags, pos); binaryDictionaryInfo->getDictRoot(), flags, pos) : NOT_A_DICT_POS; const int attributesPos = hasShortcuts ? BinaryFormat::skipChildrenPosition(flags, pos) : NOT_A_DICT_POS; const int siblingPos = BinaryFormat::skipChildrenPosAndAttributes( binaryDictionaryInfo->getDictRoot(), flags, pos); Loading