Make it possible for TranslationTasks to be accessed by the LM

This commit is contained in:
XapaJIaMnu 2015-06-23 13:24:42 +01:00
parent 2a242afa34
commit aaf8397d6f
6 changed files with 21 additions and 5 deletions

View File

@ -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

View File

@ -50,6 +50,7 @@ public:
//! the input sentence being decoded
const InputType& GetSource() const;
const ttasksptr& GetTtask() const;
virtual void Decode() = 0;
// outputs

View File

@ -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 */,

View File

@ -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);
}
}

View File

@ -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));

View File

@ -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;