Added some deterministic tie-breaking to CompareHypothesisTotalScore().

This commit is contained in:
Ulrich Germann 2015-11-03 19:01:20 +00:00
parent 6be932c1f7
commit 876fe6a412
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);
}
};