#include <InMemoryPerSentenceOnDemandLM.h>
Public Member Functions | |
InMemoryPerSentenceOnDemandLM (const std::string &line) | |
~InMemoryPerSentenceOnDemandLM () | |
void | InitializeForInput (ttasksptr const &ttask) |
Called before search and collecting of translation options. | |
virtual void | SetParameter (const std::string &key, const std::string &value) |
virtual const FFState * | EmptyHypothesisState (const InputType &input) const |
return the state associated with the empty hypothesis for a given sentence | |
virtual FFState * | EvaluateWhenApplied (const Hypothesis &hypo, const FFState *ps, ScoreComponentCollection *out) const |
This interface should be implemented. Notes: When evaluating the value of this feature function, you should avoid calling hypo.GetPrevHypo(). If you need something from the "previous" hypothesis, you should store it in an FFState object which will be passed in as prev_state. If you don't do this, you will get in trouble. | |
virtual FFState * | EvaluateWhenApplied (const ChartHypothesis &cur_hypo, int featureID, ScoreComponentCollection *accumulator) const |
virtual FFState * | EvaluateWhenApplied (const Syntax::SHyperedge &hyperedge, int featureID, ScoreComponentCollection *accumulator) const |
virtual void | CalcScore (const Phrase &phrase, float &fullScore, float &ngramScore, std::size_t &oovCount) const |
virtual void | CalcScoreFromCache (const Phrase &phrase, float &fullScore, float &ngramScore, std::size_t &oovCount) const |
virtual void | IssueRequestsFor (Hypothesis &hypo, const FFState *input_state) |
virtual void | sync () |
virtual void | SetFFStateIdx (int state_idx) |
virtual void | IncrementalCallback (Incremental::Manager &manager) const |
virtual void | ReportHistoryOrder (std::ostream &out, const Phrase &phrase) const |
virtual void | EvaluateInIsolation (const Phrase &source, const TargetPhrase &targetPhrase, ScoreComponentCollection &scoreBreakdown, ScoreComponentCollection &estimatedScores) const |
bool | IsUseable (const FactorMask &mask) const |
Protected Member Functions | |
LanguageModelKen < lm::ngram::ProbingModel > & | GetPerThreadLM () const |
bool | isInitialized () const |
Protected Attributes | |
boost::thread_specific_ptr < LanguageModelKen < lm::ngram::ProbingModel > > | m_perThreadLM |
boost::thread_specific_ptr < std::string > | m_tmpFilename |
FactorType | m_factorType |
Definition at line 29 of file InMemoryPerSentenceOnDemandLM.h.
Moses::InMemoryPerSentenceOnDemandLM::InMemoryPerSentenceOnDemandLM | ( | const std::string & | line | ) |
Definition at line 20 of file InMemoryPerSentenceOnDemandLM.cpp.
References Moses::FeatureFunction::ReadParameters().
Moses::InMemoryPerSentenceOnDemandLM::~InMemoryPerSentenceOnDemandLM | ( | ) |
Definition at line 25 of file InMemoryPerSentenceOnDemandLM.cpp.
virtual void Moses::InMemoryPerSentenceOnDemandLM::CalcScore | ( | const Phrase & | phrase, | |
float & | fullScore, | |||
float & | ngramScore, | |||
std::size_t & | oovCount | |||
) | const [inline, virtual] |
Implements Moses::LanguageModel.
Definition at line 74 of file InMemoryPerSentenceOnDemandLM.h.
References Moses::LanguageModelKen< Model >::CalcScore(), GetPerThreadLM(), isInitialized(), and UTIL_THROW.
virtual void Moses::InMemoryPerSentenceOnDemandLM::CalcScoreFromCache | ( | const Phrase & | phrase, | |
float & | fullScore, | |||
float & | ngramScore, | |||
std::size_t & | oovCount | |||
) | const [inline, virtual] |
Reimplemented from Moses::LanguageModel.
Definition at line 82 of file InMemoryPerSentenceOnDemandLM.h.
References Moses::LanguageModel::CalcScoreFromCache(), GetPerThreadLM(), isInitialized(), and UTIL_THROW.
virtual const FFState* Moses::InMemoryPerSentenceOnDemandLM::EmptyHypothesisState | ( | const InputType & | input | ) | const [inline, virtual] |
return the state associated with the empty hypothesis for a given sentence
Implements Moses::LanguageModel.
Definition at line 41 of file InMemoryPerSentenceOnDemandLM.h.
References Moses::LanguageModelKen< Model >::EmptyHypothesisState(), GetPerThreadLM(), and isInitialized().
virtual void Moses::InMemoryPerSentenceOnDemandLM::EvaluateInIsolation | ( | const Phrase & | source, | |
const TargetPhrase & | targetPhrase, | |||
ScoreComponentCollection & | scoreBreakdown, | |||
ScoreComponentCollection & | estimatedScores | |||
) | const [inline, virtual] |
Reimplemented from Moses::LanguageModel.
Definition at line 130 of file InMemoryPerSentenceOnDemandLM.h.
References Moses::LanguageModel::EvaluateInIsolation(), GetPerThreadLM(), and isInitialized().
virtual FFState* Moses::InMemoryPerSentenceOnDemandLM::EvaluateWhenApplied | ( | const Syntax::SHyperedge & | hyperedge, | |
int | featureID, | |||
ScoreComponentCollection * | accumulator | |||
) | const [inline, virtual] |
Reimplemented from Moses::StatefulFeatureFunction.
Definition at line 65 of file InMemoryPerSentenceOnDemandLM.h.
References Moses::LanguageModelKen< Model >::EvaluateWhenApplied(), GetPerThreadLM(), isInitialized(), and UTIL_THROW.
virtual FFState* Moses::InMemoryPerSentenceOnDemandLM::EvaluateWhenApplied | ( | const ChartHypothesis & | cur_hypo, | |
int | featureID, | |||
ScoreComponentCollection * | accumulator | |||
) | const [inline, virtual] |
Implements Moses::StatefulFeatureFunction.
Definition at line 57 of file InMemoryPerSentenceOnDemandLM.h.
References Moses::LanguageModelKen< Model >::EvaluateWhenApplied(), GetPerThreadLM(), isInitialized(), and UTIL_THROW.
virtual FFState* Moses::InMemoryPerSentenceOnDemandLM::EvaluateWhenApplied | ( | const Hypothesis & | cur_hypo, | |
const FFState * | prev_state, | |||
ScoreComponentCollection * | accumulator | |||
) | const [inline, virtual] |
This interface should be implemented. Notes: When evaluating the value of this feature function, you should avoid calling hypo.GetPrevHypo(). If you need something from the "previous" hypothesis, you should store it in an FFState object which will be passed in as prev_state. If you don't do this, you will get in trouble.
Implements Moses::StatefulFeatureFunction.
Definition at line 49 of file InMemoryPerSentenceOnDemandLM.h.
References Moses::LanguageModelKen< Model >::EvaluateWhenApplied(), GetPerThreadLM(), isInitialized(), and UTIL_THROW.
LanguageModelKen< lm::ngram::ProbingModel > & Moses::InMemoryPerSentenceOnDemandLM::GetPerThreadLM | ( | ) | const [protected] |
Definition at line 70 of file InMemoryPerSentenceOnDemandLM.cpp.
References Moses::LanguageModelKen< Model >::LoadModel(), m_perThreadLM, m_tmpFilename, NULL, util::POPULATE_OR_READ, UTIL_THROW, and VERBOSE.
Referenced by CalcScore(), CalcScoreFromCache(), EmptyHypothesisState(), EvaluateInIsolation(), EvaluateWhenApplied(), IncrementalCallback(), InitializeForInput(), IssueRequestsFor(), ReportHistoryOrder(), SetFFStateIdx(), SetParameter(), and sync().
virtual void Moses::InMemoryPerSentenceOnDemandLM::IncrementalCallback | ( | Incremental::Manager & | manager | ) | const [inline, virtual] |
Reimplemented from Moses::LanguageModel.
Definition at line 114 of file InMemoryPerSentenceOnDemandLM.h.
References GetPerThreadLM(), Moses::LanguageModelKen< Model >::IncrementalCallback(), isInitialized(), and UTIL_THROW.
void Moses::InMemoryPerSentenceOnDemandLM::InitializeForInput | ( | ttasksptr const & | ttask | ) | [virtual] |
Called before search and collecting of translation options.
Reimplemented from Moses::FeatureFunction.
Definition at line 29 of file InMemoryPerSentenceOnDemandLM.cpp.
References GetPerThreadLM(), key, and m_tmpFilename.
bool Moses::InMemoryPerSentenceOnDemandLM::isInitialized | ( | ) | const [inline, protected] |
Definition at line 155 of file InMemoryPerSentenceOnDemandLM.h.
References m_tmpFilename, and NULL.
Referenced by CalcScore(), CalcScoreFromCache(), EmptyHypothesisState(), EvaluateInIsolation(), EvaluateWhenApplied(), IncrementalCallback(), IssueRequestsFor(), ReportHistoryOrder(), SetFFStateIdx(), and sync().
virtual void Moses::InMemoryPerSentenceOnDemandLM::IssueRequestsFor | ( | Hypothesis & | hypo, | |
const FFState * | input_state | |||
) | [inline, virtual] |
Reimplemented from Moses::LanguageModel.
Definition at line 90 of file InMemoryPerSentenceOnDemandLM.h.
References GetPerThreadLM(), isInitialized(), Moses::LanguageModel::IssueRequestsFor(), and UTIL_THROW.
bool Moses::InMemoryPerSentenceOnDemandLM::IsUseable | ( | const FactorMask & | mask | ) | const [inline, virtual] |
Implements Moses::FeatureFunction.
Definition at line 141 of file InMemoryPerSentenceOnDemandLM.h.
References m_factorType.
virtual void Moses::InMemoryPerSentenceOnDemandLM::ReportHistoryOrder | ( | std::ostream & | out, | |
const Phrase & | phrase | |||
) | const [inline, virtual] |
Reimplemented from Moses::LanguageModel.
Definition at line 122 of file InMemoryPerSentenceOnDemandLM.h.
References GetPerThreadLM(), isInitialized(), Moses::LanguageModelKen< Model >::ReportHistoryOrder(), and UTIL_THROW.
virtual void Moses::InMemoryPerSentenceOnDemandLM::SetFFStateIdx | ( | int | state_idx | ) | [inline, virtual] |
Reimplemented from Moses::LanguageModel.
Definition at line 106 of file InMemoryPerSentenceOnDemandLM.h.
References GetPerThreadLM(), isInitialized(), Moses::LanguageModel::SetFFStateIdx(), and UTIL_THROW.
virtual void Moses::InMemoryPerSentenceOnDemandLM::SetParameter | ( | const std::string & | key, | |
const std::string & | value | |||
) | [inline, virtual] |
Reimplemented from Moses::LanguageModel.
Definition at line 37 of file InMemoryPerSentenceOnDemandLM.h.
References GetPerThreadLM(), and Moses::LanguageModel::SetParameter().
virtual void Moses::InMemoryPerSentenceOnDemandLM::sync | ( | ) | [inline, virtual] |
Reimplemented from Moses::LanguageModel.
Definition at line 98 of file InMemoryPerSentenceOnDemandLM.h.
References GetPerThreadLM(), isInitialized(), Moses::LanguageModel::sync(), and UTIL_THROW.
boost::thread_specific_ptr<LanguageModelKen<lm::ngram::ProbingModel> > Moses::InMemoryPerSentenceOnDemandLM::m_perThreadLM [mutable, protected] |
boost::thread_specific_ptr<std::string> Moses::InMemoryPerSentenceOnDemandLM::m_tmpFilename [mutable, protected] |
Definition at line 151 of file InMemoryPerSentenceOnDemandLM.h.
Referenced by GetPerThreadLM(), InitializeForInput(), and isInitialized().