Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 544e891c authored by Keisuke Kuroynagi's avatar Keisuke Kuroynagi Committed by Android (Google) Code Review
Browse files

Merge "Replace NOT_VALID_WORD with NOT_A_VALID_WORD_POS"

parents 3bf996f9 8a712953
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -292,7 +292,7 @@ static inline void prof_out(void) {
// of the binary dictionary where a {key,value} string pair scheme is used.
#define LARGEST_INT_DIGIT_COUNT 11

#define NOT_VALID_WORD (-99)
#define NOT_A_VALID_WORD_POS (-99)
#define NOT_A_CODE_POINT (-1)
#define NOT_A_DISTANCE (-1)
#define NOT_A_COORDINATE (-1)
+3 −3
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ class DicNode {
        mIsUsed = true;
        mIsCachedForNextSuggestion = false;
        mDicNodeProperties.init(
                NOT_A_DICT_POS, rootGroupPos, NOT_A_DICT_POS /* attributesPos */,
                NOT_A_VALID_WORD_POS /* pos */, rootGroupPos, NOT_A_DICT_POS /* attributesPos */,
                NOT_A_CODE_POINT /* nodeCodePoint */, NOT_A_PROBABILITY /* probability */,
                false /* isTerminal */, true /* hasChildren */,
                false /* isBlacklistedOrNotAWord */, 0 /* depth */, 0 /* terminalDepth */);
@@ -125,7 +125,7 @@ class DicNode {
        mIsUsed = true;
        mIsCachedForNextSuggestion = dicNode->mIsCachedForNextSuggestion;
        mDicNodeProperties.init(
                NOT_A_DICT_POS, rootGroupPos, NOT_A_DICT_POS /* attributesPos */,
                NOT_A_VALID_WORD_POS /* pos */, rootGroupPos, NOT_A_DICT_POS /* attributesPos */,
                NOT_A_CODE_POINT /* nodeCodePoint */, NOT_A_PROBABILITY /* probability */,
                false /* isTerminal */, true /* hasChildren */,
                false /* isBlacklistedOrNotAWord */,  0 /* depth */, 0 /* terminalDepth */);
@@ -231,7 +231,7 @@ class DicNode {
    }

    bool isFirstWord() const {
        return mDicNodeState.mDicNodeStatePrevWord.getPrevWordNodePos() == NOT_VALID_WORD;
        return mDicNodeState.mDicNodeStatePrevWord.getPrevWordNodePos() == NOT_A_VALID_WORD_POS;
    }

    bool isCompletion(const int inputSize) const {
+2 −2
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ class DicNodeStatePrevWord {
 public:
    AK_FORCE_INLINE DicNodeStatePrevWord()
            : mPrevWordCount(0), mPrevWordLength(0), mPrevWordStart(0), mPrevWordProbability(0),
              mPrevWordNodePos(0) {
              mPrevWordNodePos(NOT_A_VALID_WORD_POS) {
        memset(mPrevWord, 0, sizeof(mPrevWord));
        memset(mPrevSpacePositions, 0, sizeof(mPrevSpacePositions));
    }
@@ -41,7 +41,7 @@ class DicNodeStatePrevWord {
        mPrevWordCount = 0;
        mPrevWordStart = 0;
        mPrevWordProbability = -1;
        mPrevWordNodePos = NOT_VALID_WORD;
        mPrevWordNodePos = NOT_A_VALID_WORD_POS;
        memset(mPrevSpacePositions, 0, sizeof(mPrevSpacePositions));
    }

+3 −2
Original line number Diff line number Diff line
@@ -179,8 +179,9 @@ namespace latinime {
    const int unigramProbability = node->getProbability();
    const int wordPos = node->getPos();
    const int prevWordPos = node->getPrevWordPos();
    if (NOT_VALID_WORD == wordPos || NOT_VALID_WORD == prevWordPos) {
        // Note: Normally wordPos comes from the dictionary and should never equal NOT_VALID_WORD.
    if (NOT_A_VALID_WORD_POS == wordPos || NOT_A_VALID_WORD_POS == prevWordPos) {
        // Note: Normally wordPos comes from the dictionary and should never equal
        // NOT_A_VALID_WORD_POS.
        return ProbabilityUtils::backoff(unigramProbability);
    }
    if (multiBigramMap) {
+2 −2
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ int BigramDictionary::getBigramListPositionForWord(const int *prevWord, const in
    if (0 >= prevWordLength) return 0;
    int pos = mBinaryDictionaryInfo->getStructurePolicy()->getTerminalNodePositionOfWord(
            mBinaryDictionaryInfo, prevWord, prevWordLength, forceLowerCaseSearch);
    if (NOT_VALID_WORD == pos) return 0;
    if (NOT_A_VALID_WORD_POS == pos) return 0;
    return BinaryFormat::getBigramListPositionForWordPosition(
            mBinaryDictionaryInfo->getDictRoot(), pos);
}
@@ -181,7 +181,7 @@ bool BigramDictionary::isValidBigram(const int *word0, int length0, const int *w
    if (0 == pos) return false;
    int nextWordPos = mBinaryDictionaryInfo->getStructurePolicy()->getTerminalNodePositionOfWord(
            mBinaryDictionaryInfo, word1, length1, false /* forceLowerCaseSearch */);
    if (NOT_VALID_WORD == nextWordPos) return false;
    if (NOT_A_VALID_WORD_POS == nextWordPos) return false;

    for (BinaryDictionaryBigramsIterator bigramsIt(mBinaryDictionaryInfo, pos);
            bigramsIt.hasNext(); /* no-op */) {
Loading