diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2016-09-04 14:25:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-04 14:25:23 +0300 |
commit | aa20f0467efd12645d1250ad6f6ae49b29970193 (patch) | |
tree | 7183daf2b85ca60fc59f156350b6a5e8e0fbf6d0 /moses/LM | |
parent | 9d176ce7b5211f3d80fe465601dfdcda347a2530 (diff) | |
parent | 1c8b1d6056f0c33a61e8facb60519f6ae1e7fcfc (diff) |
Merge pull request #161 from pakozm/master
Updated hashCode generation at NeuralLMWrapper.cpp
Diffstat (limited to 'moses/LM')
-rw-r--r-- | moses/LM/NeuralLMWrapper.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/moses/LM/NeuralLMWrapper.cpp b/moses/LM/NeuralLMWrapper.cpp index 634f66e7d..91107a9a2 100644 --- a/moses/LM/NeuralLMWrapper.cpp +++ b/moses/LM/NeuralLMWrapper.cpp @@ -54,16 +54,21 @@ LMResult NeuralLMWrapper::GetValue(const vector<const Word*> &contextFactor, Sta //TODO: config option? m_neuralLM->set_cache(1000000); } - size_t hashCode = 0; - + vector<int> words(contextFactor.size()); - for (size_t i=0, n=contextFactor.size(); i<n; i++) { + const size_t n = contextFactor.size(); + for (size_t i=0; i<n; i++) { const Word* word = contextFactor[i]; const Factor* factor = word->GetFactor(m_factorType); const std::string string = factor->GetString().as_string(); int neuralLM_wordID = m_neuralLM->lookup_word(string); words[i] = neuralLM_wordID; - boost::hash_combine(hashCode, neuralLM_wordID); + } + // Generate hashCode for only the last n-1 words, that represents the next LM + // state + size_t hashCode = 0; + for (size_t i=1; i<n; ++i) { + boost::hash_combine(hashCode, words[i]); } double value = m_neuralLM->lookup_ngram(words); |