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:
authorHieu Hoang <hieuhoang@gmail.com>2019-01-17 17:34:55 +0300
committerHieu Hoang <hieuhoang@gmail.com>2019-01-17 17:34:55 +0300
commit49b388ac79107d96b70255d59ce556e37d6b89ad (patch)
tree9a89063b2a8d88062ac1a774250ee575c4b5889b
parent26940e714a104a243254eef934b66c68054df63e (diff)
check state object are not null before using it. For alternate weights setting where some feature functions are not used for a particular sentence
-rw-r--r--moses/Hypothesis.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/moses/Hypothesis.cpp b/moses/Hypothesis.cpp
index 0dc591ab3..5482de9f5 100644
--- a/moses/Hypothesis.cpp
+++ b/moses/Hypothesis.cpp
@@ -415,8 +415,11 @@ size_t Hypothesis::hash() const
// states
for (size_t i = 0; i < m_ffStates.size(); ++i) {
const FFState *state = m_ffStates[i];
- size_t hash = state->hash();
- boost::hash_combine(seed, hash);
+
+ if (state) {
+ size_t hash = state->hash();
+ boost::hash_combine(seed, hash);
+ }
}
return seed;
}
@@ -430,10 +433,15 @@ bool Hypothesis::operator==(const Hypothesis& other) const
// states
for (size_t i = 0; i < m_ffStates.size(); ++i) {
- const FFState &thisState = *m_ffStates[i];
- const FFState &otherState = *other.m_ffStates[i];
- if (thisState != otherState) {
- return false;
+ const FFState *thisState = m_ffStates[i];
+
+ if (thisState) {
+ const FFState *otherState = other.m_ffStates[i];
+ assert(otherState);
+
+ if ((*thisState) != (*otherState)) {
+ return false;
+ }
}
}
return true;