Merge "Have mPrevWordCount in DicNodeProperties."
This commit is contained in:
commit
66989a868a
1 changed files with 11 additions and 6 deletions
|
@ -32,7 +32,7 @@ class DicNodeProperties {
|
||||||
public:
|
public:
|
||||||
AK_FORCE_INLINE DicNodeProperties()
|
AK_FORCE_INLINE DicNodeProperties()
|
||||||
: mChildrenPtNodeArrayPos(NOT_A_DICT_POS), mDicNodeCodePoint(NOT_A_CODE_POINT),
|
: mChildrenPtNodeArrayPos(NOT_A_DICT_POS), mDicNodeCodePoint(NOT_A_CODE_POINT),
|
||||||
mWordId(NOT_A_WORD_ID), mDepth(0), mLeavingDepth(0) {}
|
mWordId(NOT_A_WORD_ID), mDepth(0), mLeavingDepth(0), mPrevWordCount(0) {}
|
||||||
|
|
||||||
~DicNodeProperties() {}
|
~DicNodeProperties() {}
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ class DicNodeProperties {
|
||||||
mDepth = depth;
|
mDepth = depth;
|
||||||
mLeavingDepth = leavingDepth;
|
mLeavingDepth = leavingDepth;
|
||||||
prevWordIds.copyToArray(&mPrevWordIds, 0 /* offset */);
|
prevWordIds.copyToArray(&mPrevWordIds, 0 /* offset */);
|
||||||
|
mPrevWordCount = prevWordIds.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init for root with prevWordsPtNodePos which is used for n-gram
|
// Init for root with prevWordsPtNodePos which is used for n-gram
|
||||||
|
@ -55,6 +56,7 @@ class DicNodeProperties {
|
||||||
mDepth = 0;
|
mDepth = 0;
|
||||||
mLeavingDepth = 0;
|
mLeavingDepth = 0;
|
||||||
prevWordIds.copyToArray(&mPrevWordIds, 0 /* offset */);
|
prevWordIds.copyToArray(&mPrevWordIds, 0 /* offset */);
|
||||||
|
mPrevWordCount = prevWordIds.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void initByCopy(const DicNodeProperties *const dicNodeProp) {
|
void initByCopy(const DicNodeProperties *const dicNodeProp) {
|
||||||
|
@ -63,8 +65,9 @@ class DicNodeProperties {
|
||||||
mWordId = dicNodeProp->mWordId;
|
mWordId = dicNodeProp->mWordId;
|
||||||
mDepth = dicNodeProp->mDepth;
|
mDepth = dicNodeProp->mDepth;
|
||||||
mLeavingDepth = dicNodeProp->mLeavingDepth;
|
mLeavingDepth = dicNodeProp->mLeavingDepth;
|
||||||
WordIdArrayView::fromArray(dicNodeProp->mPrevWordIds)
|
const WordIdArrayView prevWordIdArrayView = dicNodeProp->getPrevWordIds();
|
||||||
.copyToArray(&mPrevWordIds, 0 /* offset */);
|
prevWordIdArrayView.copyToArray(&mPrevWordIds, 0 /* offset */);
|
||||||
|
mPrevWordCount = prevWordIdArrayView.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init as passing child
|
// Init as passing child
|
||||||
|
@ -74,8 +77,9 @@ class DicNodeProperties {
|
||||||
mWordId = dicNodeProp->mWordId;
|
mWordId = dicNodeProp->mWordId;
|
||||||
mDepth = dicNodeProp->mDepth + 1; // Increment the depth of a passing child
|
mDepth = dicNodeProp->mDepth + 1; // Increment the depth of a passing child
|
||||||
mLeavingDepth = dicNodeProp->mLeavingDepth;
|
mLeavingDepth = dicNodeProp->mLeavingDepth;
|
||||||
WordIdArrayView::fromArray(dicNodeProp->mPrevWordIds)
|
const WordIdArrayView prevWordIdArrayView = dicNodeProp->getPrevWordIds();
|
||||||
.copyToArray(&mPrevWordIds, 0 /* offset */);
|
prevWordIdArrayView.copyToArray(&mPrevWordIds, 0 /* offset */);
|
||||||
|
mPrevWordCount = prevWordIdArrayView.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getChildrenPtNodeArrayPos() const {
|
int getChildrenPtNodeArrayPos() const {
|
||||||
|
@ -104,7 +108,7 @@ class DicNodeProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
const WordIdArrayView getPrevWordIds() const {
|
const WordIdArrayView getPrevWordIds() const {
|
||||||
return WordIdArrayView::fromArray(mPrevWordIds);
|
return WordIdArrayView::fromArray(mPrevWordIds).limit(mPrevWordCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getWordId() const {
|
int getWordId() const {
|
||||||
|
@ -121,6 +125,7 @@ class DicNodeProperties {
|
||||||
uint16_t mDepth;
|
uint16_t mDepth;
|
||||||
uint16_t mLeavingDepth;
|
uint16_t mLeavingDepth;
|
||||||
WordIdArray<MAX_PREV_WORD_COUNT_FOR_N_GRAM> mPrevWordIds;
|
WordIdArray<MAX_PREV_WORD_COUNT_FOR_N_GRAM> mPrevWordIds;
|
||||||
|
size_t mPrevWordCount;
|
||||||
};
|
};
|
||||||
} // namespace latinime
|
} // namespace latinime
|
||||||
#endif // LATINIME_DIC_NODE_PROPERTIES_H
|
#endif // LATINIME_DIC_NODE_PROPERTIES_H
|
||||||
|
|
Loading…
Reference in a new issue