mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
Added some deterministic tie-breaking to CompareHypothesisTotalScore().
This commit is contained in:
parent
6be932c1f7
commit
876fe6a412
@ -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
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user