#include <DALMWrapper.h>
Public Member Functions | |
LanguageModelDALM (const std::string &line) | |
virtual | ~LanguageModelDALM () |
void | Load (AllOptions::ptr const &opts) |
override to load model files | |
virtual const FFState * | EmptyHypothesisState (const InputType &) const |
return the state associated with the empty hypothesis for a given sentence | |
virtual void | CalcScore (const Phrase &phrase, float &fullScore, float &ngramScore, size_t &oovCount) const |
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 &hypo, int featureID, ScoreComponentCollection *out) const |
virtual bool | IsUseable (const FactorMask &mask) const |
virtual void | SetParameter (const std::string &key, const std::string &value) |
Protected Member Functions | |
void | CreateVocabMapping (const std::string &wordstxt) |
DALM::VocabId | GetVocabId (const Factor *factor) const |
Protected Attributes | |
const Factor * | m_beginSentenceFactor |
FactorType | m_factorType |
std::string | m_filePath |
size_t | m_nGramOrder |
size_t | m_ContextSize |
max n-gram length contained in this LM | |
DALM::Logger * | m_logger |
DALM::Vocabulary * | m_vocab |
DALM::LM * | m_lm |
DALM::VocabId | wid_start |
DALM::VocabId | wid_end |
std::vector< DALM::VocabId > | m_vocabMap |
Definition at line 25 of file DALMWrapper.h.
Moses::LanguageModelDALM::LanguageModelDALM | ( | const std::string & | line | ) |
Definition at line 190 of file DALMWrapper.cpp.
References m_factorType, NOT_FOUND, and Moses::FeatureFunction::ReadParameters().
Moses::LanguageModelDALM::~LanguageModelDALM | ( | ) | [virtual] |
void Moses::LanguageModelDALM::CalcScore | ( | const Phrase & | phrase, | |
float & | fullScore, | |||
float & | ngramScore, | |||
size_t & | oovCount | |||
) | const [virtual] |
Definition at line 258 of file DALMWrapper.cpp.
References Moses::Word::GetFactor(), Moses::Phrase::GetSize(), GetVocabId(), Moses::Phrase::GetWord(), Moses::Word::IsNonTerminal(), m_beginSentenceFactor, m_ContextSize, m_factorType, m_lm, m_vocab, state, and Moses::TransformLMScore().
void Moses::LanguageModelDALM::CreateVocabMapping | ( | const std::string & | wordstxt | ) | [protected] |
Definition at line 490 of file DALMWrapper.cpp.
References Moses::FactorCollection::AddFactor(), Moses::Factor::GetId(), Moses::FactorCollection::Instance(), m_vocab, and m_vocabMap.
Referenced by Load().
const FFState * Moses::LanguageModelDALM::EmptyHypothesisState | ( | const InputType & | input | ) | const [virtual] |
return the state associated with the empty hypothesis for a given sentence
Implements Moses::LanguageModel.
Definition at line 251 of file DALMWrapper.cpp.
References Moses::DALMState::get_state(), and m_lm.
FFState * Moses::LanguageModelDALM::EvaluateWhenApplied | ( | const ChartHypothesis & | hypo, | |
int | featureID, | |||
ScoreComponentCollection * | out | |||
) | const [virtual] |
Implements Moses::StatefulFeatureFunction.
Definition at line 391 of file DALMWrapper.cpp.
References Moses::TargetPhrase::GetAlignNonTerm(), Moses::ChartHypothesis::GetCurrTargetPhrase(), Moses::Word::GetFactor(), Moses::ChartHypothesis::GetFFState(), Moses::AlignmentInfo::GetNonTermIndexMap(), Moses::DALMChartState::GetPrefixFragments(), Moses::DALMChartState::GetPrefixLength(), Moses::ChartHypothesis::GetPrevHypo(), Moses::DALMChartState::GetRightContext(), Moses::ChartTranslationOption::GetScores(), Moses::ScoreComponentCollection::GetScoresForProducer(), Moses::Phrase::GetSize(), Moses::ChartHypothesis::GetTranslationOption(), Moses::Phrase::GetWord(), Moses::Word::IsNonTerminal(), m_beginSentenceFactor, m_factorType, m_lm, Moses::LanguageModel::OOVFeatureEnabled(), Moses::ScoreComponentCollection::PlusEquals(), Moses::DALMChartState::SetAsLarge(), state, and Moses::TransformLMScore().
FFState * Moses::LanguageModelDALM::EvaluateWhenApplied | ( | const Hypothesis & | cur_hypo, | |
const FFState * | prev_state, | |||
ScoreComponentCollection * | accumulator | |||
) | const [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 339 of file DALMWrapper.cpp.
References begin, end, Moses::DALMState::get_state(), Moses::Hypothesis::GetCurrTargetLength(), Moses::Hypothesis::GetCurrTargetWordsRange(), Moses::Range::GetEndPos(), Moses::Word::GetFactor(), Moses::Range::GetStartPos(), GetVocabId(), Moses::Hypothesis::GetWord(), Moses::Hypothesis::IsSourceCompleted(), m_factorType, m_lm, m_nGramOrder, NULL, Moses::LanguageModel::OOVFeatureEnabled(), Moses::ScoreComponentCollection::PlusEquals(), state, Moses::TransformLMScore(), and wid_end.
DALM::VocabId Moses::LanguageModelDALM::GetVocabId | ( | const Factor * | factor | ) | const [protected] |
Definition at line 520 of file DALMWrapper.cpp.
References Moses::Factor::GetId(), m_vocab, and m_vocabMap.
Referenced by CalcScore(), and EvaluateWhenApplied().
bool Moses::LanguageModelDALM::IsUseable | ( | const FactorMask & | mask | ) | const [virtual] |
Implements Moses::FeatureFunction.
Definition at line 485 of file DALMWrapper.cpp.
References m_factorType.
void Moses::LanguageModelDALM::Load | ( | AllOptions::ptr const & | opts | ) | [virtual] |
override to load model files
Reimplemented from Moses::FeatureFunction.
Definition at line 207 of file DALMWrapper.cpp.
References Moses::FactorCollection::AddFactor(), BOS_, CreateVocabMapping(), EOS_, Moses::FactorCollection::Instance(), LM, m_beginSentenceFactor, m_filePath, m_lm, m_logger, m_nGramOrder, m_vocab, read_ini(), UTIL_THROW_IF, wid_end, and wid_start.
void Moses::LanguageModelDALM::SetParameter | ( | const std::string & | key, | |
const std::string & | value | |||
) | [virtual] |
Reimplemented from Moses::LanguageModel.
Definition at line 526 of file DALMWrapper.cpp.
References m_ContextSize, m_factorType, m_filePath, and m_nGramOrder.
const Factor* Moses::LanguageModelDALM::m_beginSentenceFactor [protected] |
Definition at line 46 of file DALMWrapper.h.
Referenced by CalcScore(), EvaluateWhenApplied(), and Load().
size_t Moses::LanguageModelDALM::m_ContextSize [protected] |
max n-gram length contained in this LM
Definition at line 52 of file DALMWrapper.h.
Referenced by CalcScore(), and SetParameter().
FactorType Moses::LanguageModelDALM::m_factorType [protected] |
Definition at line 48 of file DALMWrapper.h.
Referenced by CalcScore(), EvaluateWhenApplied(), IsUseable(), LanguageModelDALM(), and SetParameter().
std::string Moses::LanguageModelDALM::m_filePath [protected] |
DALM::LM* Moses::LanguageModelDALM::m_lm [protected] |
Definition at line 56 of file DALMWrapper.h.
Referenced by CalcScore(), EmptyHypothesisState(), EvaluateWhenApplied(), Load(), and ~LanguageModelDALM().
DALM::Logger* Moses::LanguageModelDALM::m_logger [protected] |
size_t Moses::LanguageModelDALM::m_nGramOrder [protected] |
Definition at line 51 of file DALMWrapper.h.
Referenced by EvaluateWhenApplied(), Load(), and SetParameter().
DALM::Vocabulary* Moses::LanguageModelDALM::m_vocab [protected] |
Definition at line 55 of file DALMWrapper.h.
Referenced by CalcScore(), CreateVocabMapping(), GetVocabId(), Load(), and ~LanguageModelDALM().
std::vector<DALM::VocabId> Moses::LanguageModelDALM::m_vocabMap [mutable, protected] |
DALM::VocabId Moses::LanguageModelDALM::wid_end [protected] |
DALM::VocabId Moses::LanguageModelDALM::wid_start [protected] |