diff options
author | Hieu Hoang <hieu@hoang.co.uk> | 2013-09-27 12:35:24 +0400 |
---|---|---|
committer | Hieu Hoang <hieu@hoang.co.uk> | 2013-09-27 12:35:24 +0400 |
commit | 31ce9b510e9a06e998ddddfbe92f0192cf7656b8 (patch) | |
tree | 3bfd084ffb9eb72abe1a560cee0be3b5dc0ace7b /moses/ChartTranslationOptions.cpp | |
parent | 13e1adf0002c00b84ff9735d5afddb7e0b73530e (diff) |
beautify
Diffstat (limited to 'moses/ChartTranslationOptions.cpp')
-rw-r--r-- | moses/ChartTranslationOptions.cpp | 77 |
1 files changed, 37 insertions, 40 deletions
diff --git a/moses/ChartTranslationOptions.cpp b/moses/ChartTranslationOptions.cpp index bcfca72a5..e31667d37 100644 --- a/moses/ChartTranslationOptions.cpp +++ b/moses/ChartTranslationOptions.cpp @@ -72,7 +72,7 @@ void ChartTranslationOptions::Evaluate(const InputType &input, const InputPath & { SetInputPath(&inputPath); if (StaticData::Instance().GetPlaceholderFactor() != NOT_FOUND) { - CreateSourceRuleFromInputPath(); + CreateSourceRuleFromInputPath(); } CollType::iterator iter; @@ -88,52 +88,49 @@ void ChartTranslationOptions::SetInputPath(const InputPath *inputPath) { CollType::iterator iter; for (iter = m_collection.begin(); iter != m_collection.end(); ++iter) { - ChartTranslationOption &transOpt = **iter; - transOpt.SetInputPath(inputPath); + ChartTranslationOption &transOpt = **iter; + transOpt.SetInputPath(inputPath); } } void ChartTranslationOptions::CreateSourceRuleFromInputPath() { - if (m_collection.size() == 0) { - return; - } - - const InputPath *inputPath = m_collection.front()->GetInputPath(); - CHECK(inputPath); - std::vector<const Word*> &ruleSourceFromInputPath = inputPath->AddRuleSourceFromInputPath(); - - size_t chartCellIndex = 0; - const ChartCellLabel *chartCellLabel = (chartCellIndex < m_stackVec.size()) ? m_stackVec[chartCellIndex] : NULL; - - size_t ind = 0; - for (size_t sourcePos = m_wordsRange->GetStartPos(); sourcePos <= m_wordsRange->GetEndPos(); ++sourcePos, ++ind) { - if (chartCellLabel) { - if (sourcePos == chartCellLabel->GetCoverage().GetEndPos()) { - // end of child range. push an empty word to denote non-term - ruleSourceFromInputPath.push_back(NULL); - ++chartCellIndex; - chartCellLabel = (chartCellIndex < m_stackVec.size()) ? m_stackVec[chartCellIndex] : NULL; - } - else if (sourcePos >= chartCellLabel->GetCoverage().GetStartPos()) { - // in the range of child hypo. do nothing - } - else { - // not yet reached child range. add word - ruleSourceFromInputPath.push_back(&inputPath->GetPhrase().GetWord(ind)); - } - } - else { - // no child in sight. add word - ruleSourceFromInputPath.push_back(&inputPath->GetPhrase().GetWord(ind)); - } - } - - // save it to each trans opt + if (m_collection.size() == 0) { + return; + } + + const InputPath *inputPath = m_collection.front()->GetInputPath(); + CHECK(inputPath); + std::vector<const Word*> &ruleSourceFromInputPath = inputPath->AddRuleSourceFromInputPath(); + + size_t chartCellIndex = 0; + const ChartCellLabel *chartCellLabel = (chartCellIndex < m_stackVec.size()) ? m_stackVec[chartCellIndex] : NULL; + + size_t ind = 0; + for (size_t sourcePos = m_wordsRange->GetStartPos(); sourcePos <= m_wordsRange->GetEndPos(); ++sourcePos, ++ind) { + if (chartCellLabel) { + if (sourcePos == chartCellLabel->GetCoverage().GetEndPos()) { + // end of child range. push an empty word to denote non-term + ruleSourceFromInputPath.push_back(NULL); + ++chartCellIndex; + chartCellLabel = (chartCellIndex < m_stackVec.size()) ? m_stackVec[chartCellIndex] : NULL; + } else if (sourcePos >= chartCellLabel->GetCoverage().GetStartPos()) { + // in the range of child hypo. do nothing + } else { + // not yet reached child range. add word + ruleSourceFromInputPath.push_back(&inputPath->GetPhrase().GetWord(ind)); + } + } else { + // no child in sight. add word + ruleSourceFromInputPath.push_back(&inputPath->GetPhrase().GetWord(ind)); + } + } + + // save it to each trans opt CollType::iterator iter; for (iter = m_collection.begin(); iter != m_collection.end(); ++iter) { - ChartTranslationOption &transOpt = **iter; - transOpt.SetSourceRuleFromInputPath(&ruleSourceFromInputPath); + ChartTranslationOption &transOpt = **iter; + transOpt.SetSourceRuleFromInputPath(&ruleSourceFromInputPath); } } |