diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2015-10-13 18:24:22 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2015-10-13 18:24:22 +0300 |
commit | 0dd07cda0b79ac9bdc0499e4a908655d58ddab98 (patch) | |
tree | b0df9ac64de29c0cb8cf2ebf7986ead327e0b58a /moses/FF/TargetNgramFeature.cpp | |
parent | 4ea806a159d92e86fd6b3670ca59da3ec69e8713 (diff) |
new FF state API for more FF
Diffstat (limited to 'moses/FF/TargetNgramFeature.cpp')
-rw-r--r-- | moses/FF/TargetNgramFeature.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/moses/FF/TargetNgramFeature.cpp b/moses/FF/TargetNgramFeature.cpp index 8414e1bc2..f39a388ef 100644 --- a/moses/FF/TargetNgramFeature.cpp +++ b/moses/FF/TargetNgramFeature.cpp @@ -37,6 +37,37 @@ int TargetNgramState::Compare(const FFState& other) const } } +size_t TargetNgramState::hash() const +{ + std::size_t ret = boost::hash_range(m_words.begin(), m_words.end()); + return ret; +} +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; + } +} + +//////////////////////////////////////////////////////////////////////////// TargetNgramFeature::TargetNgramFeature(const std::string &line) :StatefulFeatureFunction(0, line) { |