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
diff options
context:
space:
mode:
authorHieu Hoang <hieu@hoang.co.uk>2013-05-28 20:35:06 +0400
committerHieu Hoang <hieu@hoang.co.uk>2013-05-28 20:35:06 +0400
commitb5bb5007738f731a55178dde5ab085b53422f22d (patch)
treed30df75839c9a07a0ccb753c580b200ab0d1f954 /moses/Incremental.cpp
parent266a81c9cf00627c396b7158866fc5f4757775dd (diff)
move GetFirstLM() as static method of LanguageModel
Diffstat (limited to 'moses/Incremental.cpp')
-rw-r--r--moses/Incremental.cpp29
1 files changed, 3 insertions, 26 deletions
diff --git a/moses/Incremental.cpp b/moses/Incremental.cpp
index 95d976521..3eb66fb0e 100644
--- a/moses/Incremental.cpp
+++ b/moses/Incremental.cpp
@@ -184,7 +184,7 @@ Manager::~Manager() {
}
template <class Model, class Best> search::History Manager::PopulateBest(const Model &model, const std::vector<lm::WordIndex> &words, Best &out) {
- const LanguageModel &abstract = GetFirstLM();
+ const LanguageModel &abstract = LanguageModel::GetFirstLM();
const float oov_weight = abstract.OOVFeatureEnabled() ? abstract.GetOOVWeight() : 0.0;
const StaticData &data = StaticData::Instance();
search::Config config(abstract.GetWeight(), data.GetCubePruningPopLimit(), search::NBestConfig(data.GetNBestSize()));
@@ -238,7 +238,7 @@ template void Manager::LMCallback<lm::ngram::ArrayTrieModel>(const lm::ngram::Ar
template void Manager::LMCallback<lm::ngram::QuantArrayTrieModel>(const lm::ngram::QuantArrayTrieModel &model, const std::vector<lm::WordIndex> &words);
const std::vector<search::Applied> &Manager::ProcessSentence() {
- GetFirstLM().IncrementalCallback(*this);
+ LanguageModel::GetFirstLM().IncrementalCallback(*this);
return *completed_nbest_;
}
@@ -285,34 +285,11 @@ void PhraseAndFeatures(const search::Applied final, Phrase &phrase, ScoreCompone
float full, ignored_ngram;
std::size_t ignored_oov;
- const LanguageModel &model = GetFirstLM();
+ const LanguageModel &model = LanguageModel::GetFirstLM();
model.CalcScore(phrase, full, ignored_ngram, ignored_oov);
// CalcScore transforms, but EvaluateChart doesn't.
features.Assign(&model, full);
}
-const LanguageModel &GetFirstLM()
-{
- static const LanguageModel *lmStatic = NULL;
-
- if (lmStatic) {
- return *lmStatic;
- }
-
- // 1st time looking up lm
- const std::vector<const StatefulFeatureFunction*> &statefulFFs = StatefulFeatureFunction::GetStatefulFeatureFunctions();
- for (size_t i = 0; i < statefulFFs.size(); ++i) {
- const StatefulFeatureFunction *ff = statefulFFs[i];
- const LanguageModel *lm = dynamic_cast<const LanguageModel*>(ff);
-
- if (lm) {
- lmStatic = lm;
- return *lmStatic;
- }
- }
-
- throw std::logic_error("Incremental search only supports one language model.");
-}
-
} // namespace Incremental
} // namespace Moses