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

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/moses/FF
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2016-03-24 01:15:14 +0300
committerKenneth Heafield <github@kheafield.com>2016-03-24 01:15:14 +0300
commit49165a370b58f2ac1f9f18664be10edd28251259 (patch)
treee711c35a363699af80df2843e5026879495249c7 /moses/FF
parent0665cb46e58c43d68c4f1cbe9a20c74abe61c165 (diff)
Pull out my config structure, still need it to go outside the ConstructOSMLM function
Diffstat (limited to 'moses/FF')
-rw-r--r--moses/FF/OSM-Feature/KenOSM.cpp20
-rw-r--r--moses/FF/OSM-Feature/KenOSM.h19
-rw-r--r--moses/FF/OSM-Feature/OpSequenceModel.cpp2
3 files changed, 20 insertions, 21 deletions
diff --git a/moses/FF/OSM-Feature/KenOSM.cpp b/moses/FF/OSM-Feature/KenOSM.cpp
index 4047406e5..25a1e6a93 100644
--- a/moses/FF/OSM-Feature/KenOSM.cpp
+++ b/moses/FF/OSM-Feature/KenOSM.cpp
@@ -3,29 +3,29 @@
namespace Moses
{
-OSMLM* ConstructOSMLM(const std::string &file)
+OSMLM* ConstructOSMLM(const char *file)
{
lm::ngram::ModelType model_type;
- if (lm::ngram::RecognizeBinary(file.c_str(), model_type)) {
-
+ lm::ngram::Config config;
+ if (lm::ngram::RecognizeBinary(file, model_type)) {
switch(model_type) {
case lm::ngram::PROBING:
- return new KenOSM<lm::ngram::ProbingModel>(file);
+ return new KenOSM<lm::ngram::ProbingModel>(file, config);
case lm::ngram::REST_PROBING:
- return new KenOSM<lm::ngram::RestProbingModel>(file);
+ return new KenOSM<lm::ngram::RestProbingModel>(file, config);
case lm::ngram::TRIE:
- return new KenOSM<lm::ngram::TrieModel>(file);
+ return new KenOSM<lm::ngram::TrieModel>(file, config);
case lm::ngram::QUANT_TRIE:
- return new KenOSM<lm::ngram::QuantTrieModel>(file);
+ return new KenOSM<lm::ngram::QuantTrieModel>(file, config);
case lm::ngram::ARRAY_TRIE:
- return new KenOSM<lm::ngram::ArrayTrieModel>(file);
+ return new KenOSM<lm::ngram::ArrayTrieModel>(file, config);
case lm::ngram::QUANT_ARRAY_TRIE:
- return new KenOSM<lm::ngram::QuantArrayTrieModel>(file);
+ 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);
+ return new KenOSM<lm::ngram::ProbingModel>(file, config);
}
}
diff --git a/moses/FF/OSM-Feature/KenOSM.h b/moses/FF/OSM-Feature/KenOSM.h
index 4975b559b..b5fa66ab9 100644
--- a/moses/FF/OSM-Feature/KenOSM.h
+++ b/moses/FF/OSM-Feature/KenOSM.h
@@ -2,7 +2,6 @@
#include <string>
#include "lm/model.hh"
-#include <boost/shared_ptr.hpp>
namespace Moses
{
@@ -12,7 +11,7 @@ class KenOSMBase
public:
virtual ~KenOSMBase() {}
- virtual float Score(const lm::ngram::State&, const std::string&,
+ virtual float Score(const lm::ngram::State&, StringPiece,
lm::ngram::State&) const = 0;
virtual const lm::ngram::State &BeginSentenceState() const = 0;
@@ -24,31 +23,31 @@ template <class KenModel>
class KenOSM : public KenOSMBase
{
public:
- KenOSM(const std::string& file)
- : m_kenlm(new KenModel(file.c_str())) {}
+ KenOSM(const char *file, const lm::ngram::Config &config)
+ : m_kenlm(file, config) {}
float Score(const lm::ngram::State &in_state,
- const std::string& word,
+ StringPiece word,
lm::ngram::State &out_state) const {
- return m_kenlm->Score(in_state, m_kenlm->GetVocabulary().Index(word),
+ return m_kenlm.Score(in_state, m_kenlm.GetVocabulary().Index(word),
out_state);
}
const lm::ngram::State &BeginSentenceState() const {
- return m_kenlm->BeginSentenceState();
+ return m_kenlm.BeginSentenceState();
}
const lm::ngram::State &NullContextState() const {
- return m_kenlm->NullContextState();
+ return m_kenlm.NullContextState();
}
private:
- boost::shared_ptr<KenModel> m_kenlm;
+ KenModel m_kenlm;
};
typedef KenOSMBase OSMLM;
-OSMLM* ConstructOSMLM(const std::string &file);
+OSMLM* ConstructOSMLM(const char *file);
} // namespace
diff --git a/moses/FF/OSM-Feature/OpSequenceModel.cpp b/moses/FF/OSM-Feature/OpSequenceModel.cpp
index 3dd694876..4118c8690 100644
--- a/moses/FF/OSM-Feature/OpSequenceModel.cpp
+++ b/moses/FF/OSM-Feature/OpSequenceModel.cpp
@@ -27,7 +27,7 @@ OpSequenceModel::~OpSequenceModel()
void OpSequenceModel :: readLanguageModel(const char *lmFile)
{
string unkOp = "_TRANS_SLF_";
- OSM = ConstructOSMLM(m_lmPath);
+ OSM = ConstructOSMLM(m_lmPath.c_str());
State startState = OSM->NullContextState();
State endState;