diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2015-02-06 14:53:25 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2015-02-06 14:53:25 +0300 |
commit | 65f94e615b266c6b02e94c71d76a131c897222fb (patch) | |
tree | 50805162c7f47e1ad394e6b80dfa6c7d9ee7c678 /moses | |
parent | 8b61f396a7558bf628c2e94a9583023b9ae34a8c (diff) |
check args for KENLM
Diffstat (limited to 'moses')
-rw-r--r-- | moses/LM/Ken.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/moses/LM/Ken.cpp b/moses/LM/Ken.cpp index 71f300481..ab2e5df80 100644 --- a/moses/LM/Ken.cpp +++ b/moses/LM/Ken.cpp @@ -146,6 +146,8 @@ template <class Model> LanguageModelKen<Model>::LanguageModelKen(const std::stri :LanguageModel(line) ,m_factorType(factorType) { + ReadParameters(); + lm::ngram::Config config; IFVERBOSE(1) { config.messages = &std::cerr; @@ -441,15 +443,18 @@ bool LanguageModelKen<Model>::IsUseable(const FactorMask &mask) const return ret; } -LanguageModel *ConstructKenLM(const std::string &line) +LanguageModel *ConstructKenLM(const std::string &lineOrig) { FactorType factorType = 0; string filePath; bool lazy = false; - util::TokenIter<util::SingleCharacter, true> argument(line, ' '); + util::TokenIter<util::SingleCharacter, true> argument(lineOrig, ' '); ++argument; // KENLM + stringstream line; + line << "KENLM"; + for (; argument; ++argument) { const char *equals = std::find(argument->data(), argument->data() + argument->size(), '='); UTIL_THROW_IF2(equals == argument->data() + argument->size(), @@ -465,12 +470,12 @@ LanguageModel *ConstructKenLM(const std::string &line) } else if (name == "lazyken") { lazy = boost::lexical_cast<bool>(value); } else { - // that's ok. do nothing, passes onto LM constructor - //UTIL_THROW2("Unknown KenLM argument " << name); + // pass to bases class to interpret + line << " " << name << "=" << value; } } - return ConstructKenLM(line, filePath, factorType, lazy); + return ConstructKenLM(line.str(), filePath, factorType, lazy); } LanguageModel *ConstructKenLM(const std::string &line, const std::string &file, FactorType factorType, bool lazy) |