Welcome to mirror list, hosted at ThFree Co, Russian Federation.

KenOSM.cpp « OSM « FF « moses2 « contrib - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6b410fc9e6b2b45a9ec695b5b832efefcef3b806 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "KenOSM.h"

namespace Moses2
{

OSMLM* ConstructOSMLM(const char *file, util::LoadMethod load_method)
{
  lm::ngram::ModelType model_type;
  lm::ngram::Config config;
  config.load_method = load_method;
  if (lm::ngram::RecognizeBinary(file, model_type)) {
    switch(model_type) {
    case lm::ngram::PROBING:
      return new KenOSM<lm::ngram::ProbingModel>(file, config);
    case lm::ngram::REST_PROBING:
      return new KenOSM<lm::ngram::RestProbingModel>(file, config);
    case lm::ngram::TRIE:
      return new KenOSM<lm::ngram::TrieModel>(file, config);
    case lm::ngram::QUANT_TRIE:
      return new KenOSM<lm::ngram::QuantTrieModel>(file, config);
    case lm::ngram::ARRAY_TRIE:
      return new KenOSM<lm::ngram::ArrayTrieModel>(file, config);
    case lm::ngram::QUANT_ARRAY_TRIE:
      return new KenOSM<lm::ngram::QuantArrayTrieModel>(file, config);
    default:
      UTIL_THROW2("Unrecognized kenlm model type " << model_type);
    }
  } else {
    return new KenOSM<lm::ngram::ProbingModel>(file, config);
  }
}

} // namespace