fixed precision

This commit is contained in:
Hieu Hoang 2016-08-14 20:56:08 +01:00
parent dffe9c2cca
commit 6db5165038
5 changed files with 16 additions and 1 deletions

View File

@ -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;

View File

@ -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 << "| ";
}

View File

@ -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) {

View File

@ -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();

View File

@ -340,5 +340,12 @@ S& Container(std::priority_queue<T, S, C>& 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);
}
}