-
Notifications
You must be signed in to change notification settings - Fork 0
/
virtual_interface.cc
53 lines (47 loc) · 1.73 KB
/
virtual_interface.cc
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "virtual_interface.hh"
#include "lm_exception.hh"
#include <memory>
#include "model.hh"
#include "model_type.hh"
#include "config.hh"
#include <iostream>
namespace lm
{
namespace base
{
Vocabulary::~Vocabulary() {}
void Vocabulary::SetSpecial(WordIndex begin_sentence, WordIndex end_sentence, WordIndex not_found)
{
begin_sentence_ = begin_sentence;
end_sentence_ = end_sentence;
not_found_ = not_found;
}
Model::~Model() {}
::std::unique_ptr<base::Model> LoadVirtualPtr(const ::std::string &file_name, const ::lm::ngram::Config &config)
{
lm::ngram::ModelType model_type = lm::ngram::ModelType::PROBING;
lm::ngram::RecognizeBinary(file_name.c_str(), model_type);
switch (model_type)
{
case lm::ngram::PROBING:
return ::std::make_unique<::lm::ngram::ProbingModel>(file_name.c_str(), config);
case lm::ngram::REST_PROBING:
return ::std::make_unique<::lm::ngram::RestProbingModel>(file_name.c_str(), config);
case lm::ngram::TRIE:
return ::std::make_unique<::lm::ngram::TrieModel>(file_name.c_str(), config);
case lm::ngram::QUANT_TRIE:
return ::std::make_unique<::lm::ngram::QuantTrieModel>(file_name.c_str(), config);
case lm::ngram::ARRAY_TRIE:
return ::std::make_unique<::lm::ngram::ArrayTrieModel>(file_name.c_str(), config);
case lm::ngram::QUANT_ARRAY_TRIE:
return ::std::make_unique<::lm::ngram::QuantArrayTrieModel>(file_name.c_str(), config);
default:
UTIL_THROW(FormatLoadException, "Confused by model type " << model_type);
}
}
std::unique_ptr<Config> Config_Create()
{
return std::make_unique<Config>();
}
} // namespace base
} // namespace lm