diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2015-10-13 19:12:10 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2015-10-13 19:12:10 +0300 |
commit | ed4ea135614dda708207f9741e2e372a43b55113 (patch) | |
tree | ae2698fb048671a495d41a411f0f4e3244b60efb /moses/FF | |
parent | 3653f37e888d1e1904aa28aec452e620edd640a1 (diff) |
new FF state API for more FF
Diffstat (limited to 'moses/FF')
-rw-r--r-- | moses/FF/ControlRecombination.cpp | 15 | ||||
-rw-r--r-- | moses/FF/ControlRecombination.h | 5 | ||||
-rw-r--r-- | moses/FF/PhraseOrientationFeature.cpp | 5 | ||||
-rw-r--r-- | moses/FF/PhraseOrientationFeature.h | 5 | ||||
-rw-r--r-- | moses/FF/TargetNgramFeature.cpp | 42 |
5 files changed, 43 insertions, 29 deletions
diff --git a/moses/FF/ControlRecombination.cpp b/moses/FF/ControlRecombination.cpp index 072163288..774446c7b 100644 --- a/moses/FF/ControlRecombination.cpp +++ b/moses/FF/ControlRecombination.cpp @@ -61,6 +61,21 @@ size_t ControlRecombinationState::hash() const return ret; } +bool ControlRecombinationState::operator==(const FFState& other) const +{ + const ControlRecombinationState &otherFF = static_cast<const ControlRecombinationState&>(other); + + if (m_ff.GetType() == SameOutput) { + int ret = m_outputPhrase.Compare(otherFF.m_outputPhrase); + return ret == 0; + } else { + // compare hypo address. Won't be equal unless they're actually the same hypo + if (m_hypo == otherFF.m_hypo) + return true; + return (m_hypo == otherFF.m_hypo); + } +} + std::vector<float> ControlRecombination::DefaultWeights() const { UTIL_THROW_IF2(m_numScoreComponents, diff --git a/moses/FF/ControlRecombination.h b/moses/FF/ControlRecombination.h index dd6febff4..bed671534 100644 --- a/moses/FF/ControlRecombination.h +++ b/moses/FF/ControlRecombination.h @@ -28,10 +28,7 @@ public: int Compare(const FFState& other) const; virtual size_t hash() const; - virtual bool operator==(const FFState& other) const - { - UTIL_THROW2("TODO:Haven't figure this out yet"); - } + virtual bool operator==(const FFState& other) const; const Phrase &GetPhrase() const { return m_outputPhrase; diff --git a/moses/FF/PhraseOrientationFeature.cpp b/moses/FF/PhraseOrientationFeature.cpp index 94ce0788a..f189dc2d2 100644 --- a/moses/FF/PhraseOrientationFeature.cpp +++ b/moses/FF/PhraseOrientationFeature.cpp @@ -26,6 +26,11 @@ size_t PhraseOrientationFeatureState::hash() const UTIL_THROW2("TODO:Haven't figure this out yet"); } +bool PhraseOrientationFeatureState::operator==(const FFState& other) const +{ + UTIL_THROW2("TODO:Haven't figure this out yet"); +} + //////////////////////////////////////////////////////////////////////////////// const std::string PhraseOrientationFeature::MORIENT("M"); const std::string PhraseOrientationFeature::SORIENT("S"); diff --git a/moses/FF/PhraseOrientationFeature.h b/moses/FF/PhraseOrientationFeature.h index d02e55107..0ed40927e 100644 --- a/moses/FF/PhraseOrientationFeature.h +++ b/moses/FF/PhraseOrientationFeature.h @@ -141,10 +141,7 @@ public: }; virtual size_t hash() const; - virtual bool operator==(const FFState& other) const - { - UTIL_THROW2("TODO:Haven't figure this out yet"); - } + virtual bool operator==(const FFState& other) const; protected: diff --git a/moses/FF/TargetNgramFeature.cpp b/moses/FF/TargetNgramFeature.cpp index f39a388ef..b74af4694 100644 --- a/moses/FF/TargetNgramFeature.cpp +++ b/moses/FF/TargetNgramFeature.cpp @@ -44,27 +44,27 @@ size_t TargetNgramState::hash() const } bool TargetNgramState::operator==(const FFState& other) const { - const TargetNgramState& rhs = dynamic_cast<const TargetNgramState&>(other); - int result; - if (m_words.size() == rhs.m_words.size()) { - for (size_t i = 0; i < m_words.size(); ++i) { - result = Word::Compare(m_words[i],rhs.m_words[i]); - if (result != 0) return false; - } - return true; - } else if (m_words.size() < rhs.m_words.size()) { - for (size_t i = 0; i < m_words.size(); ++i) { - result = Word::Compare(m_words[i],rhs.m_words[i]); - if (result != 0) return false; - } - return true; - } else { - for (size_t i = 0; i < rhs.m_words.size(); ++i) { - result = Word::Compare(m_words[i],rhs.m_words[i]); - if (result != 0) return false; - } - return true; - } + const TargetNgramState& rhs = dynamic_cast<const TargetNgramState&>(other); + int result; + if (m_words.size() == rhs.m_words.size()) { + for (size_t i = 0; i < m_words.size(); ++i) { + result = Word::Compare(m_words[i],rhs.m_words[i]); + if (result != 0) return false; + } + return true; + } else if (m_words.size() < rhs.m_words.size()) { + for (size_t i = 0; i < m_words.size(); ++i) { + result = Word::Compare(m_words[i],rhs.m_words[i]); + if (result != 0) return false; + } + return true; + } else { + for (size_t i = 0; i < rhs.m_words.size(); ++i) { + result = Word::Compare(m_words[i],rhs.m_words[i]); + if (result != 0) return false; + } + return true; + } } //////////////////////////////////////////////////////////////////////////// |