diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2014-12-04 21:35:19 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2014-12-04 21:35:19 +0300 |
commit | b23c00989b30a916d3a3fba98bf033dec5081699 (patch) | |
tree | 41cc1ea0903e93d24021ebfe5e2cf72063eaf0e5 /moses/IOWrapper.cpp | |
parent | 3a2f58eb2c97d03b486508db1438fb8b877f85d7 (diff) |
move OutputDetailedTreeFragmentsTranslationReport() to Manager
Diffstat (limited to 'moses/IOWrapper.cpp')
-rw-r--r-- | moses/IOWrapper.cpp | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/moses/IOWrapper.cpp b/moses/IOWrapper.cpp index d246195ad..9e3e0f57f 100644 --- a/moses/IOWrapper.cpp +++ b/moses/IOWrapper.cpp @@ -502,110 +502,6 @@ void IOWrapper::WriteApplicationContext(std::ostream &out, } } -void IOWrapper::OutputDetailedTreeFragmentsTranslationReport( - const ChartHypothesis *hypo, - const Sentence &sentence, - long translationId) -{ - if (hypo == NULL) { - return; - } - std::ostringstream out; - ApplicationContext applicationContext; - - OutputTreeFragmentsTranslationOptions(out, applicationContext, hypo, sentence, translationId); - UTIL_THROW_IF2(m_detailTreeFragmentsOutputCollector == NULL, - "No output file for tree fragments specified"); - - //Tree of full sentence - const StatefulFeatureFunction* treeStructure = StaticData::Instance().GetTreeStructure(); - if (treeStructure != NULL) { - const vector<const StatefulFeatureFunction*>& sff = StatefulFeatureFunction::GetStatefulFeatureFunctions(); - for( size_t i=0; i<sff.size(); i++ ) { - if (sff[i] == treeStructure) { - const TreeState* tree = dynamic_cast<const TreeState*>(hypo->GetFFState(i)); - out << "Full Tree " << translationId << ": " << tree->GetTree()->GetString() << "\n"; - break; - } - } - } - - m_detailTreeFragmentsOutputCollector->Write(translationId, out.str()); - -} - -void IOWrapper::OutputDetailedTreeFragmentsTranslationReport( - const search::Applied *applied, - const Sentence &sentence, - long translationId) -{ - if (applied == NULL) { - return; - } - std::ostringstream out; - ApplicationContext applicationContext; - - OutputTreeFragmentsTranslationOptions(out, applicationContext, applied, sentence, translationId); - UTIL_THROW_IF2(m_detailTreeFragmentsOutputCollector == NULL, - "No output file for tree fragments specified"); - - //Tree of full sentence - //TODO: incremental search doesn't support stateful features - - m_detailTreeFragmentsOutputCollector->Write(translationId, out.str()); - -} - -void IOWrapper::OutputTreeFragmentsTranslationOptions(std::ostream &out, ApplicationContext &applicationContext, const ChartHypothesis *hypo, const Sentence &sentence, long translationId) -{ - - if (hypo != NULL) { - OutputTranslationOption(out, applicationContext, hypo, sentence, translationId); - - const TargetPhrase &currTarPhr = hypo->GetCurrTargetPhrase(); - - out << " ||| "; - if (const PhraseProperty *property = currTarPhr.GetProperty("Tree")) { - out << " " << *property->GetValueString(); - } else { - out << " " << "noTreeInfo"; - } - out << std::endl; - } - - // recursive - const std::vector<const ChartHypothesis*> &prevHypos = hypo->GetPrevHypos(); - std::vector<const ChartHypothesis*>::const_iterator iter; - for (iter = prevHypos.begin(); iter != prevHypos.end(); ++iter) { - const ChartHypothesis *prevHypo = *iter; - OutputTreeFragmentsTranslationOptions(out, applicationContext, prevHypo, sentence, translationId); - } -} - -void IOWrapper::OutputTreeFragmentsTranslationOptions(std::ostream &out, ApplicationContext &applicationContext, const search::Applied *applied, const Sentence &sentence, long translationId) -{ - - if (applied != NULL) { - OutputTranslationOption(out, applicationContext, applied, sentence, translationId); - - const TargetPhrase &currTarPhr = *static_cast<const TargetPhrase*>(applied->GetNote().vp); - - out << " ||| "; - if (const PhraseProperty *property = currTarPhr.GetProperty("Tree")) { - out << " " << *property->GetValueString(); - } else { - out << " " << "noTreeInfo"; - } - out << std::endl; - } - - // recursive - const search::Applied *child = applied->Children(); - for (size_t i = 0; i < applied->GetArity(); i++) { - OutputTreeFragmentsTranslationOptions(out, applicationContext, child++, sentence, translationId); - } -} - /*** * print surface factor only for the given phrase */ |