Move initialization logic for from DicNode to DicNodeState.

Change-Id: Ic7075349e2e9c7f4ca707efa12ad1d24b49a2c87
main
Keisuke Kuroyanagi 2014-03-10 18:38:29 +09:00
parent 258260bef2
commit 6066069f35
2 changed files with 20 additions and 14 deletions

View File

@ -130,21 +130,9 @@ class DicNode {
NOT_A_PROBABILITY /* probability */, false /* isTerminal */,
true /* hasChildren */, false /* isBlacklistedOrNotAWord */, 0 /* depth */,
0 /* terminalDepth */);
// TODO: Move to dicNodeState?
mDicNodeState.mDicNodeStateOutput.init(); // reset for next word
mDicNodeState.mDicNodeStateInput.init(
&dicNode->mDicNodeState.mDicNodeStateInput, true /* resetTerminalDiffCost */);
mDicNodeState.mDicNodeStateScoring.init(
&dicNode->mDicNodeState.mDicNodeStateScoring);
mDicNodeState.mDicNodeStatePrevWord.init(
dicNode->mDicNodeState.mDicNodeStatePrevWord.getPrevWordCount() + 1,
mDicNodeState.initAsRootWithPreviousWord(&dicNode->mDicNodeState,
dicNode->mDicNodeProperties.getPtNodePos(),
dicNode->mDicNodeState.mDicNodeStatePrevWord.mPrevWord,
dicNode->mDicNodeState.mDicNodeStatePrevWord.getPrevWordLength(),
dicNode->getOutputWordBuf(),
dicNode->mDicNodeProperties.getDepth(),
dicNode->mDicNodeState.mDicNodeStatePrevWord.getSecondWordFirstInputIndex(),
mDicNodeState.mDicNodeStateInput.getInputIndex(0) /* lastInputIndex */);
dicNode->mDicNodeProperties.getDepth());
PROF_NODE_COPY(&dicNode->mProfiler, mProfiler);
}

View File

@ -58,6 +58,24 @@ class DicNodeState {
mDicNodeStateScoring.init();
}
// Init with previous word.
void initAsRootWithPreviousWord(const DicNodeState *prevWordDicNodeState,
const int prevWordPos, const int prevWordCodePointCount) {
mDicNodeStateOutput.init(); // reset for next word
mDicNodeStateInput.init(
&prevWordDicNodeState->mDicNodeStateInput, true /* resetTerminalDiffCost */);
mDicNodeStateScoring.init(&prevWordDicNodeState->mDicNodeStateScoring);
mDicNodeStatePrevWord.init(
prevWordDicNodeState->mDicNodeStatePrevWord.getPrevWordCount() + 1,
prevWordPos,
prevWordDicNodeState->mDicNodeStatePrevWord.mPrevWord,
prevWordDicNodeState->mDicNodeStatePrevWord.getPrevWordLength(),
prevWordDicNodeState->mDicNodeStateOutput.mCodePointsBuf,
prevWordCodePointCount,
prevWordDicNodeState->mDicNodeStatePrevWord.getSecondWordFirstInputIndex(),
prevWordDicNodeState->mDicNodeStateInput.getInputIndex(0) /* lastInputIndex */);
}
// Init by copy
AK_FORCE_INLINE void init(const DicNodeState *const src) {
mDicNodeStateInput.init(&src->mDicNodeStateInput);