LexicalReorderingState* HierarchicalReorderingForwardState::Expand(const TranslationOption& topt, Scores& scores) const { const LexicalReorderingConfiguration::ModelType modelType = m_configuration.GetModelType(); const WordsRange currWordsRange = topt.GetSourceWordsRange(); // keep track of the current coverage ourselves so we don't need the hypothesis WordsBitmap coverage = m_coverage; coverage.SetValue(currWordsRange.GetStartPos(), currWordsRange.GetEndPos(), true); ReorderingType reoType; if (m_first) { ClearScores(scores); } else { if (modelType == LexicalReorderingConfiguration::MSD) { reoType = GetOrientationTypeMSD(currWordsRange, coverage); } else if (modelType == LexicalReorderingConfiguration::MSLR) { reoType = GetOrientationTypeMSLR(currWordsRange, coverage); } else if (modelType == LexicalReorderingConfiguration::Monotonic) { reoType = GetOrientationTypeMonotonic(currWordsRange, coverage); } else { reoType = GetOrientationTypeLeftRight(currWordsRange, coverage); } CopyScores(scores, topt, reoType); } return new HierarchicalReorderingForwardState(this, topt); }
LexicalReorderingState* PhraseBasedReorderingState::Expand(const TranslationOption& topt, Scores& scores) const { ReorderingType reoType; const WordsRange currWordsRange = topt.GetSourceWordsRange(); const LexicalReorderingConfiguration::ModelType modelType = m_configuration.GetModelType(); if (m_direction == LexicalReorderingConfiguration::Forward && m_first) { ClearScores(scores); } else { if (!m_first || m_useFirstBackwardScore) { if (modelType == LexicalReorderingConfiguration::MSD) { reoType = GetOrientationTypeMSD(currWordsRange); } else if (modelType == LexicalReorderingConfiguration::MSLR) { reoType = GetOrientationTypeMSLR(currWordsRange); } else if (modelType == LexicalReorderingConfiguration::Monotonic) { reoType = GetOrientationTypeMonotonic(currWordsRange); } else { reoType = GetOrientationTypeLeftRight(currWordsRange); } CopyScores(scores, topt, reoType); } } return new PhraseBasedReorderingState(this, topt); }
LexicalReorderingState* HierarchicalReorderingBackwardState::Expand(const TranslationOption& topt, Scores& scores) const { HierarchicalReorderingBackwardState* nextState = new HierarchicalReorderingBackwardState(this, topt, m_reoStack); ReorderingType reoType; const LexicalReorderingConfiguration::ModelType modelType = m_configuration.GetModelType(); int reoDistance = nextState->m_reoStack.ShiftReduce(topt.GetSourceWordsRange()); if (modelType == LexicalReorderingConfiguration::MSD) { reoType = GetOrientationTypeMSD(reoDistance); } else if (modelType == LexicalReorderingConfiguration::MSLR) { reoType = GetOrientationTypeMSLR(reoDistance); } else if (modelType == LexicalReorderingConfiguration::LeftRight) { reoType = GetOrientationTypeLeftRight(reoDistance); } else { reoType = GetOrientationTypeMonotonic(reoDistance); } CopyScores(scores, topt, reoType); return nextState; }