diff --git a/contrib/moses2/Main.cpp b/contrib/moses2/Main.cpp index e3dd79a5a..2ade7ea75 100644 --- a/contrib/moses2/Main.cpp +++ b/contrib/moses2/Main.cpp @@ -11,6 +11,7 @@ #include "legacy/Parameter.h" #include "legacy/ThreadPool.h" #include "legacy/Timer.h" +#include "legacy/Util2.h" #include "util/usage.hh" using namespace std; diff --git a/contrib/moses2/PhraseBased/Hypothesis.cpp b/contrib/moses2/PhraseBased/Hypothesis.cpp index 13a33d3a2..5d6cd6933 100644 --- a/contrib/moses2/PhraseBased/Hypothesis.cpp +++ b/contrib/moses2/PhraseBased/Hypothesis.cpp @@ -158,7 +158,7 @@ void Hypothesis::OutputToStream(std::ostream &out) const out << m_path->range.GetStartPos() << "-" << m_path->range.GetEndPos() << ","; // score breakdown - out << m_scores->Debug(m_mgr->system); + m_scores->OutputBreakdown(out, m_mgr->system); out << "| "; } diff --git a/contrib/moses2/PhraseBased/Manager.cpp b/contrib/moses2/PhraseBased/Manager.cpp index dc0753371..d22f33439 100644 --- a/contrib/moses2/PhraseBased/Manager.cpp +++ b/contrib/moses2/PhraseBased/Manager.cpp @@ -192,6 +192,8 @@ void Manager::CalcFutureScore() std::string Manager::OutputBest() const { stringstream out; + Moses2::FixPrecision(out); + const Hypothesis *bestHypo = m_search->GetBestHypo(); if (bestHypo) { if (system.options.output.ReportHypoScore) { @@ -225,6 +227,8 @@ std::string Manager::OutputNBest() // MAIN LOOP stringstream out; + Moses2::FixPrecision(out); + size_t maxIter = system.options.nbest.nbest_size * system.options.nbest.factor; size_t bestInd = 0; for (size_t i = 0; i < maxIter; ++i) { diff --git a/contrib/moses2/SCFG/Manager.cpp b/contrib/moses2/SCFG/Manager.cpp index e43e5810e..f4ef94c95 100644 --- a/contrib/moses2/SCFG/Manager.cpp +++ b/contrib/moses2/SCFG/Manager.cpp @@ -319,6 +319,8 @@ std::string Manager::OutputBest() const //cerr << "BEST TRANSLATION: " << bestHypo << bestHypo->Debug(system) << endl; //cerr << " " << out.str() << endl; stringstream outStrm; + Moses2::FixPrecision(outStrm); + bestHypo->OutputToStream(outStrm); out = outStrm.str(); @@ -342,6 +344,7 @@ std::string Manager::OutputBest() const std::string Manager::OutputNBest() { stringstream out; + Moses2::FixPrecision(out); arcLists.Sort(); diff --git a/contrib/moses2/legacy/Util2.h b/contrib/moses2/legacy/Util2.h index 48650b913..eef638f93 100644 --- a/contrib/moses2/legacy/Util2.h +++ b/contrib/moses2/legacy/Util2.h @@ -340,5 +340,12 @@ S& Container(std::priority_queue& q) #define HERE __FILE__ << ":" << __LINE__ +/** Enforce rounding */ +inline void FixPrecision(std::ostream& stream, size_t size = 3) +{ + stream.setf(std::ios::fixed); + stream.precision(size); +} + }