diff --git a/contrib/other-builds/moses2/AlignmentInfo.cpp b/contrib/other-builds/moses2/AlignmentInfo.cpp index a512430eb..1887ca80a 100644 --- a/contrib/other-builds/moses2/AlignmentInfo.cpp +++ b/contrib/other-builds/moses2/AlignmentInfo.cpp @@ -18,6 +18,7 @@ ***********************************************************************/ #include #include +#include #include "AlignmentInfo.h" #include "legacy/Util2.h" #include "util/exception.hh" @@ -156,13 +157,15 @@ std::vector AlignmentInfo::GetSourceIndex2PosMap() const return ret; } -std::ostream &AlignmentInfo::Debug(std::ostream &out, const System &system) const +std::string AlignmentInfo::Debug(const System &system) const { + std::stringstream out; + AlignmentInfo::const_iterator iter; for (iter = begin(); iter != end(); ++iter) { out << iter->first << "-" << iter->second << " "; } - return out; + return out.str(); } } diff --git a/contrib/other-builds/moses2/AlignmentInfo.h b/contrib/other-builds/moses2/AlignmentInfo.h index 93971eb32..95969dee1 100644 --- a/contrib/other-builds/moses2/AlignmentInfo.h +++ b/contrib/other-builds/moses2/AlignmentInfo.h @@ -94,7 +94,7 @@ public: m_nonTermIndexMap == rhs.m_nonTermIndexMap; } - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; private: //! AlignmentInfo objects should only be created by an AlignmentInfoCollection diff --git a/contrib/other-builds/moses2/HypothesisBase.h b/contrib/other-builds/moses2/HypothesisBase.h index 7470ddd19..b007f7b44 100644 --- a/contrib/other-builds/moses2/HypothesisBase.h +++ b/contrib/other-builds/moses2/HypothesisBase.h @@ -46,7 +46,7 @@ public: virtual SCORE GetFutureScore() const = 0; virtual void EvaluateWhenApplied() = 0; - virtual std::ostream &Debug(std::ostream &out, const System &system) const = 0; + virtual std::string Debug(const System &system) const = 0; protected: ManagerBase *m_mgr; diff --git a/contrib/other-builds/moses2/HypothesisColl.cpp b/contrib/other-builds/moses2/HypothesisColl.cpp index c02ac12ca..7e0168077 100644 --- a/contrib/other-builds/moses2/HypothesisColl.cpp +++ b/contrib/other-builds/moses2/HypothesisColl.cpp @@ -5,12 +5,15 @@ * Author: hieu */ #include +#include #include #include #include "HypothesisColl.h" #include "ManagerBase.h" #include "System.h" +using namespace std; + namespace Moses2 { @@ -124,14 +127,15 @@ void HypothesisColl::Clear() m_coll.clear(); } -std::ostream &HypothesisColl::Debug(std::ostream &out, const System &system) const +std::string HypothesisColl::Debug(const System &system) const { + stringstream out; BOOST_FOREACH (const HypothesisBase *hypo, m_coll) { - hypo->Debug(out, system); + out << hypo->Debug(system); out << std::endl << std::endl; } - return out; + return out.str(); } } /* namespace Moses2 */ diff --git a/contrib/other-builds/moses2/HypothesisColl.h b/contrib/other-builds/moses2/HypothesisColl.h index 9d7859de9..7bd539628 100644 --- a/contrib/other-builds/moses2/HypothesisColl.h +++ b/contrib/other-builds/moses2/HypothesisColl.h @@ -63,7 +63,7 @@ public: const ManagerBase &mgr, ArcLists &arcLists) const; - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; protected: _HCType m_coll; diff --git a/contrib/other-builds/moses2/Phrase.h b/contrib/other-builds/moses2/Phrase.h index 497d70910..e7d0888a4 100644 --- a/contrib/other-builds/moses2/Phrase.h +++ b/contrib/other-builds/moses2/Phrase.h @@ -9,6 +9,7 @@ #include #include +#include #include #include "Word.h" #include "MemPool.h" @@ -94,19 +95,19 @@ public: virtual SubPhrase GetSubPhrase(size_t start, size_t size) const = 0; - virtual std::ostream &Debug(std::ostream &out, const System &system) const + virtual std::string Debug(const System &system) const { + std::stringstream out; size_t size = GetSize(); if (size) { - (*this)[0].Debug(out, system); + out << (*this)[0].Debug(system); for (size_t i = 1; i < size; ++i) { const WORD &word = (*this)[i]; - out << " "; - word.Debug(out, system); + out << " " << word.Debug(system); } } - return out; + return out.str(); } virtual void OutputToStream(std::ostream &out) const diff --git a/contrib/other-builds/moses2/PhraseBased/Batch/Stacks.cpp b/contrib/other-builds/moses2/PhraseBased/Batch/Stacks.cpp index 1bed0c7bd..ac836ecf8 100644 --- a/contrib/other-builds/moses2/PhraseBased/Batch/Stacks.cpp +++ b/contrib/other-builds/moses2/PhraseBased/Batch/Stacks.cpp @@ -39,8 +39,9 @@ void Stacks::Init(const Manager &mgr, size_t numStacks) } } -std::ostream &Stacks::Debug(std::ostream &out, const System &system) const +std::string Stacks::Debug(const System &system) const { + stringstream out; for (size_t i = 0; i < GetSize(); ++i) { const Stack *stack = m_stacks[i]; if (stack) { @@ -50,7 +51,7 @@ std::ostream &Stacks::Debug(std::ostream &out, const System &system) const out << "N "; } } - return out; + return out.str(); } void Stacks::Add(Hypothesis *hypo, Recycler &hypoRecycle, diff --git a/contrib/other-builds/moses2/PhraseBased/Batch/Stacks.h b/contrib/other-builds/moses2/PhraseBased/Batch/Stacks.h index 758487713..8cd2d857f 100644 --- a/contrib/other-builds/moses2/PhraseBased/Batch/Stacks.h +++ b/contrib/other-builds/moses2/PhraseBased/Batch/Stacks.h @@ -51,7 +51,7 @@ public: void Add(Hypothesis *hypo, Recycler &hypoRecycle, ArcLists &arcLists); - std::ostream & Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; protected: const Manager &m_mgr; diff --git a/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Misc.cpp b/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Misc.cpp index 6731bb320..53f60554e 100644 --- a/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Misc.cpp +++ b/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Misc.cpp @@ -91,10 +91,11 @@ CubeEdge::CubeEdge(Manager &mgr, const Hypotheses &hypos, const InputPath &path, estimatedScore = mgr.GetEstimatedScores().CalcEstimatedScore(newBitmap); } -std::ostream &CubeEdge::Debug(std::ostream &out, const System &system) const +std::string CubeEdge::Debug(const System &system) const { + stringstream out; out << newBitmap; - return out; + return out.str(); } bool CubeEdge::SetSeenPosition(const size_t x, const size_t y, diff --git a/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Misc.h b/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Misc.h index 65f7259eb..f50ee412f 100644 --- a/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Misc.h +++ b/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Misc.h @@ -88,7 +88,7 @@ public: SeenPositions &seenPositions, std::deque > &queueItemRecycler); - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; protected: diff --git a/contrib/other-builds/moses2/PhraseBased/Hypothesis.cpp b/contrib/other-builds/moses2/PhraseBased/Hypothesis.cpp index c97bff0a0..6277099b0 100644 --- a/contrib/other-builds/moses2/PhraseBased/Hypothesis.cpp +++ b/contrib/other-builds/moses2/PhraseBased/Hypothesis.cpp @@ -107,8 +107,10 @@ bool Hypothesis::operator==(const Hypothesis &other) const return ret; } -std::ostream &Hypothesis::Debug(std::ostream &out, const System &system) const +std::string Hypothesis::Debug(const System &system) const { + stringstream out; + // coverage out << GetBitmap() << " " << GetInputPath().range << " "; @@ -122,12 +124,12 @@ std::ostream &Hypothesis::Debug(std::ostream &out, const System &system) const } // string - Debug(out, m_mgr->system); + //Debug(out, m_mgr->system); out << " "; out << "fc=" << GetFutureScore() << " "; - GetScores().Debug(out, GetManager().system); + out << GetScores().Debug(GetManager().system); - return out; + return out.str(); } void Hypothesis::OutputToStream(std::ostream &out) const @@ -156,7 +158,7 @@ void Hypothesis::OutputToStream(std::ostream &out) const out << m_path->range.GetStartPos() << "-" << m_path->range.GetEndPos() << ","; // score breakdown - m_scores->Debug(out, m_mgr->system); + out << m_scores->Debug(m_mgr->system); out << "| "; } diff --git a/contrib/other-builds/moses2/PhraseBased/Hypothesis.h b/contrib/other-builds/moses2/PhraseBased/Hypothesis.h index a98d20ed2..2affd8e7f 100644 --- a/contrib/other-builds/moses2/PhraseBased/Hypothesis.h +++ b/contrib/other-builds/moses2/PhraseBased/Hypothesis.h @@ -67,7 +67,7 @@ public: return *m_targetPhrase; } - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; virtual void OutputToStream(std::ostream &out) const; diff --git a/contrib/other-builds/moses2/PhraseBased/InputPath.cpp b/contrib/other-builds/moses2/PhraseBased/InputPath.cpp index 954a8ceeb..3b133ef9b 100644 --- a/contrib/other-builds/moses2/PhraseBased/InputPath.cpp +++ b/contrib/other-builds/moses2/PhraseBased/InputPath.cpp @@ -4,11 +4,14 @@ * Created on: 23 Oct 2015 * Author: hieu */ +#include #include #include "InputPath.h" #include "TargetPhrases.h" #include "../TranslationModel/PhraseTable.h" +using namespace std; + namespace Moses2 { InputPath::InputPath(MemPool &pool, const SubPhrase &subPhrase, @@ -42,11 +45,13 @@ const TargetPhrases *InputPath::GetTargetPhrases(const PhraseTable &pt) const return targetPhrases[ptInd]; } -std::ostream &InputPath::Debug(std::ostream &out, const System &system) const +std::string InputPath::Debug(const System &system) const { + stringstream out; + out << range << " "; - subPhrase.Debug(out, system); - return out; + out << subPhrase.Debug(system); + return out.str(); } } diff --git a/contrib/other-builds/moses2/PhraseBased/InputPath.h b/contrib/other-builds/moses2/PhraseBased/InputPath.h index 39ae6e0bf..285c9c1df 100644 --- a/contrib/other-builds/moses2/PhraseBased/InputPath.h +++ b/contrib/other-builds/moses2/PhraseBased/InputPath.h @@ -33,7 +33,7 @@ public: return m_isUsed; } - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; protected: bool m_isUsed; diff --git a/contrib/other-builds/moses2/PhraseBased/Manager.cpp b/contrib/other-builds/moses2/PhraseBased/Manager.cpp index 60dfb5bff..ae5e4a296 100644 --- a/contrib/other-builds/moses2/PhraseBased/Manager.cpp +++ b/contrib/other-builds/moses2/PhraseBased/Manager.cpp @@ -232,7 +232,7 @@ std::string Manager::OutputNBest() if (ok) { out << transId << " |||"; - path->Debug(out, system); + out << path->Debug(system); out << "\n"; } diff --git a/contrib/other-builds/moses2/PhraseBased/Normal/Stacks.cpp b/contrib/other-builds/moses2/PhraseBased/Normal/Stacks.cpp index 211d775fe..2a8e1ca4d 100644 --- a/contrib/other-builds/moses2/PhraseBased/Normal/Stacks.cpp +++ b/contrib/other-builds/moses2/PhraseBased/Normal/Stacks.cpp @@ -39,8 +39,9 @@ void Stacks::Init(const Manager &mgr, size_t numStacks) } } -std::ostream &Stacks::Debug(std::ostream &out, const System &system) const +std::string Stacks::Debug(const System &system) const { + stringstream out; for (size_t i = 0; i < GetSize(); ++i) { const Stack *stack = m_stacks[i]; if (stack) { @@ -50,7 +51,7 @@ std::ostream &Stacks::Debug(std::ostream &out, const System &system) const out << "N "; } } - return out; + return out.str(); } void Stacks::Add(Hypothesis *hypo, Recycler &hypoRecycle, diff --git a/contrib/other-builds/moses2/PhraseBased/Normal/Stacks.h b/contrib/other-builds/moses2/PhraseBased/Normal/Stacks.h index e1a73a13c..58626f234 100644 --- a/contrib/other-builds/moses2/PhraseBased/Normal/Stacks.h +++ b/contrib/other-builds/moses2/PhraseBased/Normal/Stacks.h @@ -51,7 +51,7 @@ public: void Add(Hypothesis *hypo, Recycler &hypoRecycle, ArcLists &arcLists); - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; protected: const Manager &m_mgr; diff --git a/contrib/other-builds/moses2/PhraseBased/Sentence.cpp b/contrib/other-builds/moses2/PhraseBased/Sentence.cpp index 477ffe7ce..54d9eb428 100644 --- a/contrib/other-builds/moses2/PhraseBased/Sentence.cpp +++ b/contrib/other-builds/moses2/PhraseBased/Sentence.cpp @@ -15,10 +15,11 @@ using namespace std; namespace Moses2 { -std::ostream &Sentence::XMLOption::Debug(std::ostream &out, const System &system) const +std::string Sentence::XMLOption::Debug(const System &system) const { + stringstream out; out << "[" << startPos << "," << phraseSize << "]=" << nodeName; - return out; + return out.str(); } ////////////////////////////////////////////////////////////////////////////// diff --git a/contrib/other-builds/moses2/PhraseBased/Sentence.h b/contrib/other-builds/moses2/PhraseBased/Sentence.h index 5bffa15d2..09324f993 100644 --- a/contrib/other-builds/moses2/PhraseBased/Sentence.h +++ b/contrib/other-builds/moses2/PhraseBased/Sentence.h @@ -30,7 +30,7 @@ public: std::string nodeName; size_t startPos, phraseSize; - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; }; diff --git a/contrib/other-builds/moses2/PhraseBased/TargetPhraseImpl.cpp b/contrib/other-builds/moses2/PhraseBased/TargetPhraseImpl.cpp index f8ad8474d..62fdc9753 100644 --- a/contrib/other-builds/moses2/PhraseBased/TargetPhraseImpl.cpp +++ b/contrib/other-builds/moses2/PhraseBased/TargetPhraseImpl.cpp @@ -5,6 +5,7 @@ * Author: hieu */ +#include #include #include "TargetPhraseImpl.h" #include "../Scores.h" @@ -48,12 +49,12 @@ TargetPhraseImpl::~TargetPhraseImpl() // TODO Auto-generated destructor stub } -std::ostream &TargetPhraseImpl::Debug(std::ostream &out, const System &system) const +std::string TargetPhraseImpl::Debug(const System &system) const { - Phrase::Debug(out, system); - out << " SCORES:"; - GetScores().Debug(out, system); - return out; + stringstream out; + out << Phrase::Debug(system); + out << " SCORES:" << GetScores().Debug(system); + return out.str(); } } diff --git a/contrib/other-builds/moses2/PhraseBased/TargetPhraseImpl.h b/contrib/other-builds/moses2/PhraseBased/TargetPhraseImpl.h index 3bc1fa94c..2e9f4860a 100644 --- a/contrib/other-builds/moses2/PhraseBased/TargetPhraseImpl.h +++ b/contrib/other-builds/moses2/PhraseBased/TargetPhraseImpl.h @@ -35,7 +35,7 @@ public: virtual ~TargetPhraseImpl(); - virtual std::ostream &Debug(std::ostream &out, const System &system) const; + virtual std::string Debug(const System &system) const; protected: }; diff --git a/contrib/other-builds/moses2/PhraseBased/TargetPhrases.cpp b/contrib/other-builds/moses2/PhraseBased/TargetPhrases.cpp index fee66d005..95fe4316c 100644 --- a/contrib/other-builds/moses2/PhraseBased/TargetPhrases.cpp +++ b/contrib/other-builds/moses2/PhraseBased/TargetPhrases.cpp @@ -38,13 +38,14 @@ TargetPhrases::~TargetPhrases() // TODO Auto-generated destructor stub } -std::ostream &TargetPhrases::Debug(std::ostream &out, const System &system) const +std::string TargetPhrases::Debug(const System &system) const { + stringstream out; BOOST_FOREACH(const TargetPhrase *tp, *this){ - tp->Debug(out, system); + out << tp->Debug(system); out << endl; } - return out; + return out.str(); } void TargetPhrases::SortAndPrune(size_t tableLimit) diff --git a/contrib/other-builds/moses2/PhraseBased/TargetPhrases.h b/contrib/other-builds/moses2/PhraseBased/TargetPhrases.h index 86d1c03d7..dc975987f 100644 --- a/contrib/other-builds/moses2/PhraseBased/TargetPhrases.h +++ b/contrib/other-builds/moses2/PhraseBased/TargetPhrases.h @@ -55,7 +55,7 @@ public: void SortAndPrune(size_t tableLimit); - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; protected: Coll m_coll; diff --git a/contrib/other-builds/moses2/PhraseBased/TrellisPath.cpp b/contrib/other-builds/moses2/PhraseBased/TrellisPath.cpp index ecc2fd3aa..b396e47b3 100644 --- a/contrib/other-builds/moses2/PhraseBased/TrellisPath.cpp +++ b/contrib/other-builds/moses2/PhraseBased/TrellisPath.cpp @@ -16,10 +16,11 @@ using namespace std; namespace Moses2 { -std::ostream &TrellisNode::Debug(std::ostream &out, const System &system) const +std::string TrellisNode::Debug(const System &system) const { + stringstream out; out << "arcList=" << arcList->size() << " " << ind; - return out; + return out.str(); } ///////////////////////////////////////////////////////////////////////////////// @@ -75,17 +76,18 @@ SCORE TrellisPath::GetFutureScore() const return m_scores->GetTotalScore(); } -std::ostream &TrellisPath::Debug(std::ostream &out, const System &system) const +std::string TrellisPath::Debug(const System &system) const { + stringstream out; out << ToString(); out << "||| "; - GetScores().Debug(out, system); + out << GetScores().Debug(system); out << "||| "; out << GetScores().GetTotalScore(); - return out; + return out.str(); } std::string TrellisPath::ToString() const diff --git a/contrib/other-builds/moses2/PhraseBased/TrellisPath.h b/contrib/other-builds/moses2/PhraseBased/TrellisPath.h index c863ff632..6b1242766 100644 --- a/contrib/other-builds/moses2/PhraseBased/TrellisPath.h +++ b/contrib/other-builds/moses2/PhraseBased/TrellisPath.h @@ -34,7 +34,7 @@ public: return (*arcList)[ind]; } - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; }; @@ -64,7 +64,7 @@ public: } SCORE GetFutureScore() const; - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; std::string ToString() const; //! create a set of next best paths by wiggling 1 of the node at a time. diff --git a/contrib/other-builds/moses2/SCFG/ActiveChart.cpp b/contrib/other-builds/moses2/SCFG/ActiveChart.cpp index 8ace85dcd..f37b8fe31 100644 --- a/contrib/other-builds/moses2/SCFG/ActiveChart.cpp +++ b/contrib/other-builds/moses2/SCFG/ActiveChart.cpp @@ -57,14 +57,15 @@ std::vector SymbolBind::GetNTElements() const return ret; } -std::ostream &SymbolBind::Debug(std::ostream &out, const System &system) const +std::string SymbolBind::Debug(const System &system) const { + stringstream out; BOOST_FOREACH(const SymbolBindElement &ele, coll) { out << "("<< *ele.range; - ele.word->Debug(out, system); + out << ele.word->Debug(system); out << ") "; } - return out; + return out.str(); } //////////////////////////////////////////////////////////////////////////// diff --git a/contrib/other-builds/moses2/SCFG/ActiveChart.h b/contrib/other-builds/moses2/SCFG/ActiveChart.h index 98a2ddf6b..d8329f4b5 100644 --- a/contrib/other-builds/moses2/SCFG/ActiveChart.h +++ b/contrib/other-builds/moses2/SCFG/ActiveChart.h @@ -63,7 +63,7 @@ public: bool operator==(const SymbolBind &compare) const { return coll == compare.coll; } - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; }; diff --git a/contrib/other-builds/moses2/SCFG/CubePruning/Misc.cpp b/contrib/other-builds/moses2/SCFG/CubePruning/Misc.cpp index 0ab250107..cebbd2cc1 100644 --- a/contrib/other-builds/moses2/SCFG/CubePruning/Misc.cpp +++ b/contrib/other-builds/moses2/SCFG/CubePruning/Misc.cpp @@ -29,15 +29,16 @@ SeenPosition::SeenPosition(MemPool &pool, const SCFG::TargetPhrases *vtps, size_ } } -std::ostream &SeenPosition::Debug(std::ostream &out, const System &system) const +std::string SeenPosition::Debug(const System &system) const { + stringstream out; out << tps << " " << tpInd << " "; for (size_t i = 0; i < hypoIndColl.size(); ++i) { out << hypoIndColl[i] << " "; } - return out; + return out.str(); } bool SeenPosition::operator==(const SeenPosition &compare) const @@ -178,14 +179,15 @@ void QueueItem::CreateNext( } } -std::ostream &QueueItem::Debug(std::ostream &out, const System &system) const +std::string QueueItem::Debug(const System &system) const { + stringstream out; out << hypo << " " << &(*tps)[tpInd] << "(" << tps << " " << tpInd << ") "; for (size_t i = 0; i < hypoIndColl.size(); ++i) { out << hypoIndColl[i] << " "; } - return out; + return out.str(); } } diff --git a/contrib/other-builds/moses2/SCFG/CubePruning/Misc.h b/contrib/other-builds/moses2/SCFG/CubePruning/Misc.h index 435d0babc..2ef18194c 100644 --- a/contrib/other-builds/moses2/SCFG/CubePruning/Misc.h +++ b/contrib/other-builds/moses2/SCFG/CubePruning/Misc.h @@ -34,7 +34,7 @@ public: bool operator==(const SeenPosition &compare) const; size_t hash() const; - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; }; @@ -86,7 +86,7 @@ public: SeenPositions &seenPositions, const SCFG::InputPath &path); - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; protected: typedef Vector HyposColl; diff --git a/contrib/other-builds/moses2/SCFG/Hypothesis.cpp b/contrib/other-builds/moses2/SCFG/Hypothesis.cpp index 5450ef768..356af624d 100644 --- a/contrib/other-builds/moses2/SCFG/Hypothesis.cpp +++ b/contrib/other-builds/moses2/SCFG/Hypothesis.cpp @@ -131,16 +131,16 @@ void Hypothesis::OutputToStream(std::ostream &out) const } } -std::ostream &Hypothesis::Debug(std::ostream &out, const System &system) const +std::string Hypothesis::Debug(const System &system) const { + stringstream out; out << this; out << " RANGE:"; out << m_path->range; // score - out << " SCORE:"; - GetScores().Debug(out, GetManager().system); + out << " SCORE:" << GetScores().Debug(GetManager().system); /* out << " m_prevHypos=" << m_prevHypos.size() << " "; @@ -149,16 +149,16 @@ std::ostream &Hypothesis::Debug(std::ostream &out, const System &system) const } */ - m_targetPhrase->Debug(out, GetManager().system); + out << m_targetPhrase->Debug(GetManager().system); // recursive for (size_t i = 0; i < m_prevHypos.size(); ++i) { const Hypothesis &prevHypo = *m_prevHypos[i]; out << endl; - prevHypo.Debug(out, system); + out << prevHypo.Debug(system); } - return out; + return out.str(); } } // namespaces diff --git a/contrib/other-builds/moses2/SCFG/Hypothesis.h b/contrib/other-builds/moses2/SCFG/Hypothesis.h index 286baa7da..f32ad94a7 100644 --- a/contrib/other-builds/moses2/SCFG/Hypothesis.h +++ b/contrib/other-builds/moses2/SCFG/Hypothesis.h @@ -44,7 +44,7 @@ public: void OutputToStream(std::ostream &out) const; - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; protected: const SCFG::TargetPhraseImpl *m_targetPhrase; diff --git a/contrib/other-builds/moses2/SCFG/InputPath.cpp b/contrib/other-builds/moses2/SCFG/InputPath.cpp index 3668a8782..e9e80e5f9 100644 --- a/contrib/other-builds/moses2/SCFG/InputPath.cpp +++ b/contrib/other-builds/moses2/SCFG/InputPath.cpp @@ -37,10 +37,11 @@ InputPath::~InputPath() // TODO Auto-generated destructor stub } -std::ostream &InputPath::Debug(std::ostream &out, const System &system) const +std::string InputPath::Debug(const System &system) const { + stringstream out; out << range << " "; - subPhrase.Debug(out, system); + out << subPhrase.Debug(system); out << " " << prefixPath << " "; const Vector &activeEntries = *GetActiveChart(1).entries; @@ -48,7 +49,7 @@ std::ostream &InputPath::Debug(std::ostream &out, const System &system) const for (size_t i = 0; i < activeEntries.size(); ++i) { const ActiveChartEntry &entry = *activeEntries[i]; - entry.GetSymbolBind().Debug(out, system); + out << entry.GetSymbolBind().Debug(system); out << "| "; } @@ -59,12 +60,12 @@ std::ostream &InputPath::Debug(std::ostream &out, const System &system) const BOOST_FOREACH(const SCFG::InputPath::Coll::value_type &valPair, *targetPhrases) { const SymbolBind &symbolBind = valPair.first; const SCFG::TargetPhrases &tps = *valPair.second; - symbolBind.Debug(out, system); + out << symbolBind.Debug(system); //out << "=" << tps.GetSize() << " "; - tps.Debug(out, system); + out << tps.Debug(system); } - return out; + return out.str(); } void InputPath::AddTargetPhrase( diff --git a/contrib/other-builds/moses2/SCFG/InputPath.h b/contrib/other-builds/moses2/SCFG/InputPath.h index 16367b39e..18a6707b5 100644 --- a/contrib/other-builds/moses2/SCFG/InputPath.h +++ b/contrib/other-builds/moses2/SCFG/InputPath.h @@ -52,7 +52,7 @@ public: size_t GetNumRules() const; - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; protected: ActiveChart *m_activeChart; diff --git a/contrib/other-builds/moses2/SCFG/InputPaths.cpp b/contrib/other-builds/moses2/SCFG/InputPaths.cpp index f5a65c256..e1c3f9d21 100644 --- a/contrib/other-builds/moses2/SCFG/InputPaths.cpp +++ b/contrib/other-builds/moses2/SCFG/InputPaths.cpp @@ -67,19 +67,20 @@ void InputPaths::Init(const InputType &input, const ManagerBase &mgr) } -std::ostream &InputPaths::Debug(std::ostream &out, const System &system) const +std::string InputPaths::Debug(const System &system) const { + stringstream out; const Matrix &matrix = GetMatrix(); for (size_t i = 0; i < matrix.GetRows(); ++i) { for (size_t j = 0; j < matrix.GetCols(); ++j) { SCFG::InputPath *path = matrix.GetValue(i, j); if (path) { - path->Debug(out, system); + out << path->Debug(system); out << endl; } } } - return out; + return out.str(); } } diff --git a/contrib/other-builds/moses2/SCFG/InputPaths.h b/contrib/other-builds/moses2/SCFG/InputPaths.h index 3e3c35d06..37e2404cf 100644 --- a/contrib/other-builds/moses2/SCFG/InputPaths.h +++ b/contrib/other-builds/moses2/SCFG/InputPaths.h @@ -31,7 +31,7 @@ public: return *m_matrix; } - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; protected: Matrix *m_matrix; diff --git a/contrib/other-builds/moses2/SCFG/Manager.cpp b/contrib/other-builds/moses2/SCFG/Manager.cpp index 4d6888eed..1f228c31a 100644 --- a/contrib/other-builds/moses2/SCFG/Manager.cpp +++ b/contrib/other-builds/moses2/SCFG/Manager.cpp @@ -62,9 +62,9 @@ void Manager::Decode() cerr << endl << "startPos=" << startPos << endl; SCFG::InputPath &initPath = *m_inputPaths.GetMatrix().GetValue(startPos, 0); - //cerr << "BEFORE path=" << m_inputPaths << endl; + cerr << "BEFORE InitActiveChart=" << initPath.Debug(system) << endl; InitActiveChart(initPath); - cerr << "AFTER path=" << endl; + cerr << "AFTER InitActiveChart=" << initPath.Debug(system) << endl; int maxPhraseSize = inputSize - startPos + 1; for (int phraseSize = 1; phraseSize < maxPhraseSize; ++phraseSize) { @@ -73,14 +73,14 @@ void Manager::Decode() Stack &stack = m_stacks.GetStack(startPos, phraseSize); - cerr << "BEFORE LOOKUP path=" << endl; + cerr << "BEFORE LOOKUP path=" << path.Debug(system) << endl; Lookup(path); - cerr << "AFTER LOOKUP path=" << endl; + cerr << "AFTER LOOKUP path=" << path.Debug(system) << endl; Decode(path, stack); - cerr << "AFTER DECODE path=" << endl; + cerr << "AFTER DECODE path=" << path.Debug(system) << endl; LookupUnary(path); - //cerr << "AFTER LookupUnary path=" << path << endl; + cerr << "AFTER LookupUnary path=" << path.Debug(system) << endl; //cerr << "#rules=" << path.GetNumRules() << endl; } @@ -317,7 +317,7 @@ std::string Manager::OutputBest() const bestHypo->OutputToStream(out); cerr << "BEST TRANSLATION: "; - bestHypo->Debug(cerr, system); + cerr << bestHypo->Debug(system); cerr << " " << out.str() << endl; } else { diff --git a/contrib/other-builds/moses2/SCFG/Stack.cpp b/contrib/other-builds/moses2/SCFG/Stack.cpp index c019306a2..b1bc58c74 100644 --- a/contrib/other-builds/moses2/SCFG/Stack.cpp +++ b/contrib/other-builds/moses2/SCFG/Stack.cpp @@ -104,19 +104,19 @@ const Hypothesis *Stack::GetBestHypo( return ret; } -std::ostream &Stack::Debug(std::ostream &out, const System &system) const +std::string Stack::Debug(const System &system) const { + stringstream out; BOOST_FOREACH (const SCFG::Stack::Coll::value_type &valPair, m_coll) { const SCFG::Word &lhs = valPair.first; const Moses2::HypothesisColl &hypos = *valPair.second; - out << "lhs="; - lhs.Debug(out, system); + out << "lhs=" << lhs.Debug(system); out << "=" << hypos.GetSize() << endl; - hypos.Debug(out, system); + out << hypos.Debug(system); out << endl; } - return out; + return out.str(); } } diff --git a/contrib/other-builds/moses2/SCFG/Stack.h b/contrib/other-builds/moses2/SCFG/Stack.h index c54efe0b5..0ecaebfe6 100644 --- a/contrib/other-builds/moses2/SCFG/Stack.h +++ b/contrib/other-builds/moses2/SCFG/Stack.h @@ -39,7 +39,7 @@ public: const Manager &mgr, ArcLists &arcLists) const; - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; protected: const Manager &m_mgr; diff --git a/contrib/other-builds/moses2/SCFG/TargetPhraseImpl.cpp b/contrib/other-builds/moses2/SCFG/TargetPhraseImpl.cpp index 1fafc182e..d8be4729e 100644 --- a/contrib/other-builds/moses2/SCFG/TargetPhraseImpl.cpp +++ b/contrib/other-builds/moses2/SCFG/TargetPhraseImpl.cpp @@ -63,24 +63,23 @@ TargetPhraseImpl::~TargetPhraseImpl() // TODO Auto-generated destructor stub } -std::ostream &TargetPhraseImpl::Debug(std::ostream &out, const System &system) const +std::string TargetPhraseImpl::Debug(const System &system) const { - lhs.Debug(out, system); + stringstream out; + out << lhs.Debug(system); out << " -> "; for (size_t i = 0; i < GetSize(); ++i) { const SCFG::Word &word = (*this)[i]; - word.Debug(out, system); - out << " "; + out << word.Debug(system) << " "; } out << "pt=" << pt.GetName(); - out << " SCORES:"; - GetScores().Debug(out, system); + out << " SCORES:" << GetScores().Debug(system); out << " ALIGN:"; - GetAlignTerm().Debug(out, system); + out << GetAlignTerm().Debug(system); out << " "; - GetAlignNonTerm().Debug(out, system); + out << GetAlignNonTerm().Debug(system); - return out; + return out.str(); } void TargetPhraseImpl::SetAlignmentInfo(const std::string &alignString) diff --git a/contrib/other-builds/moses2/SCFG/TargetPhraseImpl.h b/contrib/other-builds/moses2/SCFG/TargetPhraseImpl.h index 960004672..8dbd68fcf 100644 --- a/contrib/other-builds/moses2/SCFG/TargetPhraseImpl.h +++ b/contrib/other-builds/moses2/SCFG/TargetPhraseImpl.h @@ -67,7 +67,7 @@ public: void SetAlignmentInfo(const std::string &alignString); - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; //mutable void *chartState; protected: diff --git a/contrib/other-builds/moses2/SCFG/TargetPhrases.cpp b/contrib/other-builds/moses2/SCFG/TargetPhrases.cpp index 0b57bd771..fdcdb4422 100644 --- a/contrib/other-builds/moses2/SCFG/TargetPhrases.cpp +++ b/contrib/other-builds/moses2/SCFG/TargetPhrases.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include "TargetPhrases.h" #include "TargetPhraseImpl.h" @@ -49,13 +50,15 @@ void TargetPhrases::SortAndPrune(size_t tableLimit) //cerr << "TargetPhrases=" << GetSize() << endl; } -std::ostream &TargetPhrases::Debug(std::ostream &out, const System &system) const +std::string TargetPhrases::Debug(const System &system) const { + std::stringstream out; + BOOST_FOREACH(const SCFG::TargetPhraseImpl *tp, m_coll) { out << std::endl; - tp->Debug(out, system); + out << tp->Debug(system); } - return out; + return out.str(); } } diff --git a/contrib/other-builds/moses2/SCFG/TargetPhrases.h b/contrib/other-builds/moses2/SCFG/TargetPhrases.h index ca8b9411f..22502b3ef 100644 --- a/contrib/other-builds/moses2/SCFG/TargetPhrases.h +++ b/contrib/other-builds/moses2/SCFG/TargetPhrases.h @@ -55,7 +55,7 @@ public: void SortAndPrune(size_t tableLimit); - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; protected: Coll m_coll; diff --git a/contrib/other-builds/moses2/SCFG/Word.cpp b/contrib/other-builds/moses2/SCFG/Word.cpp index b5a595b5d..2c175709d 100644 --- a/contrib/other-builds/moses2/SCFG/Word.cpp +++ b/contrib/other-builds/moses2/SCFG/Word.cpp @@ -75,16 +75,17 @@ void Word::OutputToStream(std::ostream &out) const } } -std::ostream &Word::Debug(std::ostream &out, const System &system) const +std::string Word::Debug(const System &system) const { + stringstream out; if (isNonTerminal) { out << "["; } - Moses2::Word::Debug(out, system); + out << Moses2::Word::Debug(system); if (isNonTerminal) { out << "]"; } - return out; + return out.str(); } } diff --git a/contrib/other-builds/moses2/SCFG/Word.h b/contrib/other-builds/moses2/SCFG/Word.h index 4db0b38f8..3e292f458 100644 --- a/contrib/other-builds/moses2/SCFG/Word.h +++ b/contrib/other-builds/moses2/SCFG/Word.h @@ -40,7 +40,7 @@ public: size_t hash() const; virtual void OutputToStream(std::ostream &out) const; - virtual std::ostream &Debug(std::ostream &out, const System &system) const; + virtual std::string Debug(const System &system) const; protected: }; diff --git a/contrib/other-builds/moses2/Scores.cpp b/contrib/other-builds/moses2/Scores.cpp index 78cdb42d4..3be80f7df 100644 --- a/contrib/other-builds/moses2/Scores.cpp +++ b/contrib/other-builds/moses2/Scores.cpp @@ -243,8 +243,9 @@ void Scores::CreateFromString(const std::string &str, PlusEquals(system, featureFunction, scores); } -std::ostream &Scores::Debug(std::ostream &out, const System &system) const +std::string Scores::Debug(const System &system) const { + stringstream out; out << "total=" << m_total; if (system.options.nbest.nbest_size) { @@ -257,7 +258,7 @@ std::ostream &Scores::Debug(std::ostream &out, const System &system) const } } - return out; + return out.str(); } // static functions to work out estimated scores diff --git a/contrib/other-builds/moses2/Scores.h b/contrib/other-builds/moses2/Scores.h index f8f8fd49a..963fb6962 100644 --- a/contrib/other-builds/moses2/Scores.h +++ b/contrib/other-builds/moses2/Scores.h @@ -65,7 +65,7 @@ public: void Assign(const System &system, const FeatureFunction &featureFunction, const std::vector &scores); - std::ostream &Debug(std::ostream &out, const System &system) const; + std::string Debug(const System &system) const; // static functions to work out estimated scores static SCORE CalcWeightedScore(const System &system, diff --git a/contrib/other-builds/moses2/SubPhrase.h b/contrib/other-builds/moses2/SubPhrase.h index cc972b06c..5b2cf4f04 100644 --- a/contrib/other-builds/moses2/SubPhrase.h +++ b/contrib/other-builds/moses2/SubPhrase.h @@ -1,4 +1,5 @@ #pragma once +#include #include "Phrase.h" #include "Word.h" #include "SCFG/Word.h" @@ -29,18 +30,18 @@ public: return ret; } - virtual std::ostream &Debug(std::ostream &out, const System &system) const + virtual std::string Debug(const System &system) const { + std::stringstream out; if (GetSize()) { - (*this)[0].Debug(out, system); + out << (*this)[0].Debug(system); for (size_t i = 1; i < GetSize(); ++i) { const WORD &word = (*this)[i]; - out << " "; - word.Debug(out, system); + out << " " << word.Debug(system); } } - return out; + return out.str(); } protected: diff --git a/contrib/other-builds/moses2/TargetPhrase.h b/contrib/other-builds/moses2/TargetPhrase.h index 0f237f8de..7e3d8e78e 100644 --- a/contrib/other-builds/moses2/TargetPhrase.h +++ b/contrib/other-builds/moses2/TargetPhrase.h @@ -6,6 +6,7 @@ */ #pragma once +#include #include "PhraseImplTemplate.h" #include "System.h" #include "Scores.h" @@ -45,13 +46,13 @@ public: SCORE *GetScoresProperty(int propertyInd) const { return scoreProperties ? scoreProperties + propertyInd : NULL; } - virtual std::ostream &Debug(std::ostream &out, const System &system) const + virtual std::string Debug(const System &system) const { - Phrase::Debug(out, system); - out << " SCORES:"; - GetScores().Debug(out, system); + std::stringstream out; + out << Phrase::Debug(system); + out << " SCORES:" << GetScores().Debug(system); - return out; + return out.str(); } protected: diff --git a/contrib/other-builds/moses2/TranslationModel/ProbingPT.cpp b/contrib/other-builds/moses2/TranslationModel/ProbingPT.cpp index ce8201153..48d0b43d3 100644 --- a/contrib/other-builds/moses2/TranslationModel/ProbingPT.cpp +++ b/contrib/other-builds/moses2/TranslationModel/ProbingPT.cpp @@ -405,7 +405,7 @@ void ProbingPT::InitActiveChart( const SCFG::Manager &mgr, SCFG::InputPath &path) const { - cerr << "InitActiveChart=" << path.Debug(cerr, mgr.system) << endl; + //cerr << "InitActiveChart=" << path.Debug(cerr, mgr.system) << endl; size_t ptInd = GetPtInd(); ActiveChartEntryProbing *chartEntry = new (pool.Allocate()) ActiveChartEntryProbing(pool); path.AddActiveChartEntry(ptInd, chartEntry); @@ -417,7 +417,7 @@ void ProbingPT::Lookup(MemPool &pool, const SCFG::Stacks &stacks, SCFG::InputPath &path) const { - cerr << "Lookup=" << endl; + //cerr << "Lookup=" << endl; if (path.range.GetNumWordsCovered() > maxChartSpan) { return; } @@ -521,9 +521,12 @@ void ProbingPT::LookupGivenNode( SCFG::InputPath &outPath) const { std::pair key = prevEntry.GetKey(wordSought, *this); + //cerr << "wordSought=" << wordSought.Debug(cerr, mgr.system) << " " << key.first << endl; + cerr << "wordSought=" << wordSought.Debug(mgr.system) << endl; + //cerr << "HELLO" << endl; if (!key.first) { - // should only happen when looking up unary rules + // should only occasionally happen when looking up unary rules return; } diff --git a/contrib/other-builds/moses2/Word.cpp b/contrib/other-builds/moses2/Word.cpp index b6c570863..081e1e489 100644 --- a/contrib/other-builds/moses2/Word.cpp +++ b/contrib/other-builds/moses2/Word.cpp @@ -71,8 +71,9 @@ bool Word::operator<(const Word &compare) const return (cmp < 0); } -std::ostream &Word::Debug(std::ostream &out, const System &system) const +std::string Word::Debug(const System &system) const { + stringstream out; bool outputAlready = false; for (size_t i = 0; i < MAX_NUM_FACTORS; ++i) { const Factor *factor = m_factors[i]; @@ -85,7 +86,7 @@ std::ostream &Word::Debug(std::ostream &out, const System &system) const } } - return out; + return out.str(); } void Word::OutputToStream(std::ostream &out) const diff --git a/contrib/other-builds/moses2/Word.h b/contrib/other-builds/moses2/Word.h index 23228ea9b..3c6b53592 100644 --- a/contrib/other-builds/moses2/Word.h +++ b/contrib/other-builds/moses2/Word.h @@ -53,7 +53,7 @@ public: } virtual void OutputToStream(std::ostream &out) const; - virtual std::ostream &Debug(std::ostream &out, const System &system) const; + virtual std::string Debug(const System &system) const; std::string GetString(const FactorList &factorTypes) const; protected: