00001 #include "KenOSM.h" 00002 00003 namespace Moses 00004 { 00005 00006 OSMLM* ConstructOSMLM(const char *file, util::LoadMethod load_method) 00007 { 00008 lm::ngram::ModelType model_type; 00009 lm::ngram::Config config; 00010 config.load_method = load_method; 00011 if (lm::ngram::RecognizeBinary(file, model_type)) { 00012 switch(model_type) { 00013 case lm::ngram::PROBING: 00014 return new KenOSM<lm::ngram::ProbingModel>(file, config); 00015 case lm::ngram::REST_PROBING: 00016 return new KenOSM<lm::ngram::RestProbingModel>(file, config); 00017 case lm::ngram::TRIE: 00018 return new KenOSM<lm::ngram::TrieModel>(file, config); 00019 case lm::ngram::QUANT_TRIE: 00020 return new KenOSM<lm::ngram::QuantTrieModel>(file, config); 00021 case lm::ngram::ARRAY_TRIE: 00022 return new KenOSM<lm::ngram::ArrayTrieModel>(file, config); 00023 case lm::ngram::QUANT_ARRAY_TRIE: 00024 return new KenOSM<lm::ngram::QuantArrayTrieModel>(file, config); 00025 default: 00026 UTIL_THROW2("Unrecognized kenlm model type " << model_type); 00027 } 00028 } else { 00029 return new KenOSM<lm::ngram::ProbingModel>(file, config); 00030 } 00031 } 00032 00033 } // namespace