mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-20 07:42:21 +03:00
Make some parameters of neuralLM optional
This commit is contained in:
parent
59ab036eb5
commit
b5e5e12c9f
@ -28,9 +28,9 @@ BilingualLM::BilingualLM(const std::string &line)
|
||||
}
|
||||
|
||||
void BilingualLM::Load(){
|
||||
m_neuralLM_shared = new nplm::neuralLM(m_filePath, true);
|
||||
//TODO: config option?
|
||||
m_neuralLM_shared->set_cache(1000000);
|
||||
m_neuralLM_shared = new nplm::neuralLM(m_filePath, premultiply); //Default premultiply= true
|
||||
|
||||
m_neuralLM_shared->set_cache(neuralLM_cache); //Default 1000000
|
||||
UTIL_THROW_IF2(m_nGramOrder != m_neuralLM_shared->get_order(),
|
||||
"Wrong order of neuralLM: LM has " << m_neuralLM_shared->get_order() << ", but Moses expects " << m_nGramOrder);
|
||||
}
|
||||
@ -603,6 +603,19 @@ void BilingualLM::SetParameter(const std::string& key, const std::string& value)
|
||||
target_ngrams = atoi(value.c_str());
|
||||
} else if (key == "source_ngrams") {
|
||||
source_ngrams = atoi(value.c_str());
|
||||
} else if (key == "cache_size") {
|
||||
neuralLM_cache = atoi(value.c_str());
|
||||
} else if (key == "premultiply") {
|
||||
std::string truestr = "true";
|
||||
std::string falsestr = "false";
|
||||
if (value == truestr) {
|
||||
premultiply = true;
|
||||
} else if (value == falsestr) {
|
||||
premultiply = false;
|
||||
} else {
|
||||
std::cerr << "UNRECOGNIZED OPTION FOR PARAMETER premultiply. Got " << value << " , expected true or false!" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
StatefulFeatureFunction::SetParameter(key, value);
|
||||
}
|
||||
|
@ -63,6 +63,8 @@ protected:
|
||||
int m_nGramOrder;
|
||||
int target_ngrams;
|
||||
int source_ngrams;
|
||||
bool premultiply = true;
|
||||
int neuralLM_cache = 1000000;
|
||||
const Factor* BOS_factor;
|
||||
const Factor* EOS_factor;
|
||||
// thread-specific nplm for thread-safety
|
||||
|
Loading…
Reference in New Issue
Block a user