15 #ifndef APPLYLMTASK_KENLMTYPE_HPP 16 #define APPLYLMTASK_KENLMTYPE_HPP 28 template<
class Arc,
template<
class>
class MakeWeightT>
31 , std::string
const &lmkey
32 , std::unordered_set<typename Arc::Label> &epsilons
34 , MakeWeightT<Arc> &mw
36 ,
unsigned offset = 0) {
37 using namespace lm::ngram;
38 typedef lm::np::Model NplmModel;
41 int kenmt = ucam::util::detectkenlm(file);
46 (
dynamic_cast<ProbingModel &
>(*klm.
model), epsilons,useNaturalLog, klm.
lmscale, klm.
lmwp, klm.
idb, mw);
49 (
dynamic_cast<RestProbingModel &
>(*klm.
model), epsilons,useNaturalLog, klm.
lmscale, klm.
lmwp, klm.
idb, mw);
52 (
dynamic_cast<TrieModel &
>(*klm.
model), epsilons,useNaturalLog, klm.
lmscale, klm.
lmwp, klm.
idb, mw);
55 (
dynamic_cast<QuantTrieModel &
>(*klm.
model), epsilons,useNaturalLog, klm.
lmscale, klm.
lmwp, klm.
idb, mw);
58 (
dynamic_cast<ArrayTrieModel &
>(*klm.
model), epsilons,useNaturalLog, klm.
lmscale, klm.
lmwp, klm.
idb, mw);
59 case QUANT_ARRAY_TRIE:
61 (
dynamic_cast<QuantArrayTrieModel &
>(*klm.
model), epsilons,useNaturalLog, klm.
lmscale, klm.
lmwp, klm.
idb, mw);
62 case util::KENLM_NPLM:
65 (
dynamic_cast<NplmModel &
>(*klm.
model), epsilons,useNaturalLog, klm.
lmscale, klm.
lmwp, klm.
idb, mw);
67 LERROR(
"Unsuported format: KENLM_NPLM. Did you compile NPLM library?");
71 LERROR(
"Programmer mistake -- (task.applylm.kenlmtype.hpp)");
79 template<
class Arc,
template<
class>
class MakeWeightT>
82 , std::string
const &lmkey
83 , std::unordered_set<typename Arc::Label> &epsilons
85 , MakeWeightT<Arc> &mw
87 ,
unsigned offset = 0) {
88 using namespace lm::ngram;
89 typedef lm::np::Model NplmModel;
92 int kenmt = ucam::util::detectkenlm(file);
95 case util::KENLM_NPLM:
98 (
dynamic_cast<NplmModel &
>(*klm.
model), epsilons,useNaturalLog, klm.
lmscale, klm.
lmwp, klm.
idb, mw);
100 LERROR(
"Unsuported format: KENLM_NPLM. Did you compile NPLM library?");
107 case QUANT_ARRAY_TRIE:
108 LERROR(
"Unsuported format, only NPLM supported for bilingual models. ");
112 LERROR(
"Programmer mistake -- (task.applylm.kenlmtype.hpp)");
std::vector< std::string > getVectorString(const std::string &key) const
Convenience method that returns a vector of strings taking "," as the separator character.
Class that applies language model on the fly using kenlm.