Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Denkowski <mdenkows@amazon.com>2015-09-21 18:25:55 +0300
committerMichael Denkowski <mdenkows@amazon.com>2015-09-21 18:25:55 +0300
commit5fbb69806a79586e0d797f9463fcf49d71e3ff3a (patch)
treee48ad5daf736ede92dcdac500b8297a09dfe3c6f /moses/BitmapContainer.h
parent3ec9e519d2276935a93055c4a654c93d6a91b296 (diff)
Make cube pruning deterministic
- When hypotheses have equal scores, compare current target phrases - Requires keeping a copy of the target phrase to avoid concurrency problems with other threads deleting objects while they are being compared
Diffstat (limited to 'moses/BitmapContainer.h')
-rw-r--r--moses/BitmapContainer.h25
1 files changed, 12 insertions, 13 deletions
diff --git a/moses/BitmapContainer.h b/moses/BitmapContainer.h
index 500059081..9dc901e94 100644
--- a/moses/BitmapContainer.h
+++ b/moses/BitmapContainer.h
@@ -61,6 +61,7 @@ private:
size_t m_hypothesis_pos, m_translation_pos;
Hypothesis *m_hypothesis;
BackwardsEdge *m_edge;
+ TargetPhrase m_target_phrase;
HypothesisQueueItem();
@@ -72,7 +73,8 @@ public:
: m_hypothesis_pos(hypothesis_pos)
, m_translation_pos(translation_pos)
, m_hypothesis(hypothesis)
- , m_edge(edge) {
+ , m_edge(edge)
+ , m_target_phrase(hypothesis->GetCurrTargetPhrase()) {
}
~HypothesisQueueItem() {
@@ -93,6 +95,10 @@ public:
BackwardsEdge *GetBackwardsEdge() {
return m_edge;
}
+
+ TargetPhrase& GetTargetPhrase() {
+ return m_target_phrase;
+ }
};
//! Allows comparison of two HypothesisQueueItem objects by the corresponding scores.
@@ -103,20 +109,13 @@ public:
float scoreA = itemA->GetHypothesis()->GetTotalScore();
float scoreB = itemB->GetHypothesis()->GetTotalScore();
- return (scoreA < scoreB);
-
- /*
+ if (scoreA != scoreB)
{
- return true;
+ return (scoreA < scoreB);
}
- else if (scoreA < scoreB)
- {
- return false;
- }
- else
- {
- return itemA < itemB;
- }*/
+
+ // Equal scores: break ties deterministically by comparing target phrases
+ return (itemA->GetTargetPhrase().Compare(itemB->GetTargetPhrase()) < 0);
}
};