am da5b4fb6: Merge "Move initialization logic for from DicNode to DicNodeState."

* commit 'da5b4fb6da45281630ab19684859c30cf0ca05ac':
  Move initialization logic for from DicNode to DicNodeState.
main
Keisuke Kuroyanagi 2014-03-10 04:41:52 -07:00 committed by Android Git Automerger
commit 5c4704ffad
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);