mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-25 21:03:22 +03:00
Make it possible for TranslationTasks to be accessed by the LM
This commit is contained in:
parent
2a242afa34
commit
aaf8397d6f
@ -27,6 +27,11 @@ BaseManager::GetSource() const
|
||||
return m_source;
|
||||
}
|
||||
|
||||
const ttasksptr&
|
||||
BaseManager::GetTtask() const {
|
||||
return m_ttask.lock();
|
||||
}
|
||||
|
||||
void
|
||||
BaseManager::
|
||||
OutputSearchGraphAsHypergraph(std::ostream& out) const
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
|
||||
//! the input sentence being decoded
|
||||
const InputType& GetSource() const;
|
||||
const ttasksptr& GetTtask() const;
|
||||
|
||||
virtual void Decode() = 0;
|
||||
// outputs
|
||||
|
@ -37,6 +37,14 @@ public:
|
||||
const FFState* prev_state,
|
||||
ScoreComponentCollection* accumulator) const = 0;
|
||||
|
||||
virtual FFState* EvaluateWhenAppliedWithContext(
|
||||
ttasksptr const& ttasks,
|
||||
const Hypothesis& cur_hypo,
|
||||
const FFState* prev_state,
|
||||
ScoreComponentCollection* accumulator) const {
|
||||
return EvaluateWhenApplied(cur_hypo, prev_state, accumulator);
|
||||
}
|
||||
|
||||
virtual FFState* EvaluateWhenApplied(
|
||||
const ChartHypothesis& /* cur_hypo */,
|
||||
int /* featureID - used to index the state in the previous hypotheses */,
|
||||
|
@ -230,9 +230,11 @@ EvaluateWhenApplied(StatefulFeatureFunction const& sfff,
|
||||
{
|
||||
const StaticData &staticData = StaticData::Instance();
|
||||
if (! staticData.IsFeatureFunctionIgnored( sfff )) {
|
||||
m_ffStates[state_idx]
|
||||
= sfff.EvaluateWhenApplied
|
||||
(*this, m_prevHypo ? m_prevHypo->m_ffStates[state_idx] : NULL,
|
||||
Manager& manager = this->GetManager(); //Get the manager and the ttask
|
||||
ttasksptr const& ttask = manager.GetTtask();
|
||||
|
||||
m_ffStates[state_idx] = sfff.EvaluateWhenAppliedWithContext
|
||||
(ttask, *this, m_prevHypo ? m_prevHypo->m_ffStates[state_idx] : NULL,
|
||||
&m_currScoreBreakdown);
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ void LanguageModelIRST::CalcScore(const Phrase &phrase, float &fullScore, float
|
||||
fullScore = ngramScore + before_boundary;
|
||||
}
|
||||
|
||||
FFState* LanguageModelIRST::EvaluateWhenApplied(const Hypothesis &hypo, const FFState *ps, ScoreComponentCollection *out) const
|
||||
FFState* LanguageModelIRST::EvaluateWhenAppliedWithContext(ttasksptr const& ttasks, const Hypothesis &hypo, const FFState *ps, ScoreComponentCollection *out) const
|
||||
{
|
||||
if (!hypo.GetCurrTargetLength()) {
|
||||
std::auto_ptr<IRSTLMState> ret(new IRSTLMState(ps));
|
||||
|
@ -93,7 +93,7 @@ public:
|
||||
|
||||
virtual LMResult GetValue(const std::vector<const Word*> &contextFactor, State* finalState = NULL) const;
|
||||
|
||||
virtual FFState *EvaluateWhenApplied(const Hypothesis &hypo, const FFState *ps, ScoreComponentCollection *out) const;
|
||||
virtual FFState *EvaluateWhenAppliedWithContext(ttasksptr const& ttasks, const Hypothesis &hypo, const FFState *ps, ScoreComponentCollection *out) const;
|
||||
|
||||
virtual void CalcScore(const Phrase &phrase, float &fullScore, float &ngramScore, size_t &oovCount) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user