Merge branch 'master' of github.com:moses-smt/mosesdecoder

This commit is contained in:
Hieu Hoang 2015-11-03 19:56:32 +00:00
commit c5c08993de
2 changed files with 22 additions and 6 deletions

View File

@ -632,6 +632,23 @@ OutputWordAlignment(vector<xmlrpc_c::value>& out) const
tmp[i]->OutputLocalWordAlignment(out);
}
bool
Hypothesis::
beats(Hypothesis const& b) const
{
if (m_totalScore != b.m_totalScore)
return m_totalScore > b.m_totalScore;
else if (m_futureScore != b.m_futureScore)
return m_futureScore > b.m_futureScore;
else if (m_prevHypo)
return b.m_prevHypo ? m_prevHypo->beats(*b.m_prevHypo) : true;
else return false;
// TO DO: add more tie breaking here
// results. We should compare other property of the hypos here.
// On the other hand, how likely is this going to happen?
}
#endif

View File

@ -1,6 +1,4 @@
// $Id$
// vim:tabstop=2
// -*- mode: c++; indent-tabs-mode: nil; tab-width:2 -*-
/***********************************************************************
Moses - factored phrase-based language decoder
Copyright (C) 2006 University of Edinburgh
@ -69,7 +67,6 @@ typedef std::vector<Hypothesis*> ArcList;
class Hypothesis
{
friend std::ostream& operator<<(std::ostream&, const Hypothesis&);
protected:
const Hypothesis* m_prevHypo; /*! backpointer to previous hypothesis (from which this one was created) */
const Bitmap &m_sourceCompleted; /*! keeps track of which words have been translated so far */
@ -283,6 +280,8 @@ public:
void OutputLocalWordAlignment(std::vector<xmlrpc_c::value>& dest) const;
#endif
bool beats(Hypothesis const& b) const;
};
@ -290,8 +289,8 @@ std::ostream& operator<<(std::ostream& out, const Hypothesis& hypothesis);
// sorting helper
struct CompareHypothesisTotalScore {
bool operator()(const Hypothesis* hypo1, const Hypothesis* hypo2) const {
return hypo1->GetTotalScore() > hypo2->GetTotalScore();
bool operator()(const Hypothesis* a, const Hypothesis* b) const {
return a->beats(*b);
}
};