From 7927439ce5952aa57614cb3bd906179b3aedc217 Mon Sep 17 00:00:00 2001 From: phkoehn Date: Fri, 16 Sep 2011 11:58:53 +0000 Subject: [PATCH] option to get unpruned search graph for chart decoder git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@4228 1f5c12ca-751b-0410-a591-d2e778427230 --- moses/src/ChartCell.cpp | 1 - moses/src/ChartHypothesisCollection.cpp | 3 ++- moses/src/ChartRuleLookupManagerOnDisk.cpp | 2 +- moses/src/GenerationDictionary.cpp | 2 +- moses/src/Parameter.cpp | 1 + moses/src/StaticData.cpp | 1 + moses/src/StaticData.h | 4 ++++ 7 files changed, 10 insertions(+), 4 deletions(-) diff --git a/moses/src/ChartCell.cpp b/moses/src/ChartCell.cpp index 67d58c4db..0afa7682a 100644 --- a/moses/src/ChartCell.cpp +++ b/moses/src/ChartCell.cpp @@ -190,7 +190,6 @@ void ChartCell::GetSearchGraph(long translationId, std::ostream &outputSearchGra const ChartHypothesisCollection &coll = iterOutside->second; coll.GetSearchGraph(translationId, outputSearchGraphStream, reachable); } - } std::ostream& operator<<(std::ostream &out, const ChartCell &cell) diff --git a/moses/src/ChartHypothesisCollection.cpp b/moses/src/ChartHypothesisCollection.cpp index a6fe3fd41..4eea86514 100644 --- a/moses/src/ChartHypothesisCollection.cpp +++ b/moses/src/ChartHypothesisCollection.cpp @@ -259,7 +259,8 @@ void ChartHypothesisCollection::GetSearchGraph(long translationId, std::ostream HCType::const_iterator iter; for (iter = m_hypos.begin() ; iter != m_hypos.end() ; ++iter) { ChartHypothesis &mainHypo = **iter; - if (reachable.find(mainHypo.GetId()) != reachable.end()) { + if (StaticData::Instance().GetUnprunedSearchGraph() || + reachable.find(mainHypo.GetId()) != reachable.end()) { outputSearchGraphStream << translationId << " " << mainHypo << endl; } diff --git a/moses/src/ChartRuleLookupManagerOnDisk.cpp b/moses/src/ChartRuleLookupManagerOnDisk.cpp index f450a3ecb..48933474f 100644 --- a/moses/src/ChartRuleLookupManagerOnDisk.cpp +++ b/moses/src/ChartRuleLookupManagerOnDisk.cpp @@ -254,7 +254,7 @@ void ChartRuleLookupManagerOnDisk::GetChartRuleCollection( delete tpcollBerkeleyDb; m_cache[tpCollFilePos] = targetPhraseCollection; } else { - // jsut get out of cache + // just get out of cache targetPhraseCollection = iterCache->second; } diff --git a/moses/src/GenerationDictionary.cpp b/moses/src/GenerationDictionary.cpp index fedd04886..cf4f3fe86 100644 --- a/moses/src/GenerationDictionary.cpp +++ b/moses/src/GenerationDictionary.cpp @@ -125,7 +125,7 @@ size_t GenerationDictionary::GetNumScoreComponents() const std::string GenerationDictionary::GetScoreProducerDescription(unsigned) const { - return "Generation score, file=" + m_filePath; + return "Generation score,file=" + m_filePath; } std::string GenerationDictionary::GetScoreProducerWeightShortName(unsigned) const diff --git a/moses/src/Parameter.cpp b/moses/src/Parameter.cpp index b202ad1f1..109175e9c 100644 --- a/moses/src/Parameter.cpp +++ b/moses/src/Parameter.cpp @@ -120,6 +120,7 @@ Parameter::Parameter() AddParam("time-out", "seconds after which is interrupted (-1=no time-out, default is -1)"); AddParam("output-search-graph", "osg", "Output connected hypotheses of search into specified filename"); AddParam("output-search-graph-extended", "osgx", "Output connected hypotheses of search into specified filename, in extended format"); + AddParam("unpruned-search-graph", "usg", "When outputting chart search graph, do not exclude dead ends. Note: stack pruning may have eliminated some hypotheses"); #ifdef HAVE_PROTOBUF AddParam("output-search-graph-pb", "pb", "Write phrase lattice to protocol buffer objects in the specified path."); #endif diff --git a/moses/src/StaticData.cpp b/moses/src/StaticData.cpp index 92cf481bc..7bf8bba4e 100644 --- a/moses/src/StaticData.cpp +++ b/moses/src/StaticData.cpp @@ -210,6 +210,7 @@ bool StaticData::LoadData(Parameter *parameter) } else m_outputSearchGraphPB = false; #endif + SetBooleanParameter( &m_unprunedSearchGraph, "unpruned-search-graph", true ); // include feature names in the n-best list SetBooleanParameter( &m_labeledNBestList, "labeled-n-best-list", true ); diff --git a/moses/src/StaticData.h b/moses/src/StaticData.h index b7865d40f..2ef0a0e5e 100644 --- a/moses/src/StaticData.h +++ b/moses/src/StaticData.h @@ -193,6 +193,7 @@ protected: #ifdef HAVE_PROTOBUF bool m_outputSearchGraphPB; //! whether to output search graph as a protobuf #endif + bool m_unprunedSearchGraph; //! do not exclude dead ends (chart decoder only) size_t m_cubePruningPopLimit; size_t m_cubePruningDiversity; @@ -539,6 +540,9 @@ public: return m_outputSearchGraphPB; } #endif + bool GetUnprunedSearchGraph() const { + return m_unprunedSearchGraph; + } XmlInputType GetXmlInputType() const { return m_xmlInputType;