From 6a915253e115796c9905f3b24aba782b5a055e09 Mon Sep 17 00:00:00 2001 From: Nadir Durrani Date: Mon, 1 Jul 2013 11:06:55 +0100 Subject: [PATCH] Bug Fix --- moses/FF/OSM-Feature/OpSequenceModel.cpp | 12 +++--------- moses/FF/OSM-Feature/OpSequenceModel.h | 3 +-- moses/LM/Ken.cpp | 3 ++- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/moses/FF/OSM-Feature/OpSequenceModel.cpp b/moses/FF/OSM-Feature/OpSequenceModel.cpp index 897f80d00..5b3821ddd 100644 --- a/moses/FF/OSM-Feature/OpSequenceModel.cpp +++ b/moses/FF/OSM-Feature/OpSequenceModel.cpp @@ -23,7 +23,7 @@ void OpSequenceModel :: readLanguageModel(const char *lmFile) string unkOp = "_TRANS_SLF_"; - //* + /* // Code for SRILM @@ -35,20 +35,14 @@ void OpSequenceModel :: readLanguageModel(const char *lmFile) numbers.push_back(ptrOp->getLMID(const_cast (unkOp.c_str()))); unkOpProb = ptrOp->contextProbN(numbers,nonWordFlag); - //*/ + */ // Code to load KenLM OSM = new Model(m_lmPath.c_str()); - - /* - State startState = OSM->EmptyContextState(); + State startState = OSM->BeginSentenceState(); State endState; unkOpProb = OSM->Score(startState,OSM->GetVocabulary().Index(unkOp),endState); - */ - - - } diff --git a/moses/FF/OSM-Feature/OpSequenceModel.h b/moses/FF/OSM-Feature/OpSequenceModel.h index 80d687f69..a636aded6 100644 --- a/moses/FF/OSM-Feature/OpSequenceModel.h +++ b/moses/FF/OSM-Feature/OpSequenceModel.h @@ -17,8 +17,7 @@ class OpSequenceModel : public StatefulFeatureFunction { public: - //LM *LanguageModel; - + lm::ngram::Model * OSM; Api * ptrOp; diff --git a/moses/LM/Ken.cpp b/moses/LM/Ken.cpp index 7fd2deb5a..df757386a 100644 --- a/moses/LM/Ken.cpp +++ b/moses/LM/Ken.cpp @@ -383,9 +383,10 @@ LanguageModel *ConstructKenLM(const std::string &description, const std::string try { lm::ngram::ModelType model_type; if (lm::ngram::RecognizeBinary(file.c_str(), model_type)) { + switch(model_type) { case lm::ngram::PROBING: - return new LanguageModelKen(description, line, file, factorType, lazy); + return new LanguageModelKen(description, line, file, factorType, lazy); case lm::ngram::REST_PROBING: return new LanguageModelKen(description, line, file, factorType, lazy); case lm::ngram::TRIE: