From 4ea806a159d92e86fd6b3670ca59da3ec69e8713 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Tue, 13 Oct 2015 13:17:34 +0100 Subject: new FF state API for HReorderingForwardState --- moses/FF/LexicalReordering/LexicalReorderingState.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'moses/FF') diff --git a/moses/FF/LexicalReordering/LexicalReorderingState.cpp b/moses/FF/LexicalReordering/LexicalReorderingState.cpp index 6f368b9a9..6e6ecaf46 100644 --- a/moses/FF/LexicalReordering/LexicalReorderingState.cpp +++ b/moses/FF/LexicalReordering/LexicalReorderingState.cpp @@ -512,12 +512,22 @@ Compare(const FFState& o) const size_t HReorderingForwardState::hash() const { - UTIL_THROW2("TODO:Haven't figure this out yet"); + size_t ret; + ret = hash_value(m_prevRange); + return ret; } -bool HReorderingForwardState::operator==(const FFState& other) const +bool HReorderingForwardState::operator==(const FFState& o) const { - UTIL_THROW2("TODO:Haven't figure this out yet"); + if (&o == this) return true; + + HReorderingForwardState const& other + = static_cast(o); + + int compareScores = ((m_prevRange == other.m_prevRange) + ? ComparePrevScores(other.m_prevOption) + : (m_prevRange < other.m_prevRange) ? -1 : 1); + return compareScores == 0; } // For compatibility with the phrase-based reordering model, scoring is one -- cgit v1.2.3