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
path: root/moses/LM
diff options
context:
space:
mode:
authorPaco Zamora Martinez <pakozm@gmail.com>2016-07-08 19:31:17 +0300
committerPaco Zamora Martinez <pakozm@gmail.com>2016-07-08 19:31:17 +0300
commit1c8b1d6056f0c33a61e8facb60519f6ae1e7fcfc (patch)
tree5b4ceb19c83ca6b42ea2d37ed7f57277f1b00bb9 /moses/LM
parent70927d84e0024dd751015cae7ddef9ff3c09c71b (diff)
Updated hashCode generation at NeuralLMWrapper.cpp; changed it to consider the last n-1 words instead of the whole ngram n words
Diffstat (limited to 'moses/LM')
-rw-r--r--moses/LM/NeuralLMWrapper.cpp13
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);