stateful FF framework

This commit is contained in:
Hieu Hoang 2015-10-29 13:13:01 +00:00
parent d54de8c8db
commit d58bbf158d
3 changed files with 18 additions and 0 deletions

View File

@ -123,4 +123,16 @@ void Hypothesis::EmptyHypothesisState(const Phrase &input)
}
}
void Hypothesis::EvaluateWhenApplied()
{
const std::vector<const StatefulFeatureFunction*> &sfffs = m_mgr.GetSystem().GetFeatureFunctions().GetStatefulFeatureFunctions();
BOOST_FOREACH(const StatefulFeatureFunction *sfff, sfffs) {
size_t statefulInd = sfff->GetStatefulInd();
const Moses::FFState *prevState = m_prevHypo->GetState(statefulInd);
assert(prevState);
const Moses::FFState *state = sfff->EvaluateWhenApplied(m_mgr, *this, *prevState, *m_scores);
m_ffStates[statefulInd] = state;
}
}

View File

@ -44,10 +44,15 @@ public:
const Scores &GetScores() const
{ return *m_scores; }
const Moses::FFState *GetState(size_t ind) const
{ return m_ffStates[ind]; }
void OutputToStream(std::ostream &out) const;
void EmptyHypothesisState(const Phrase &input);
void EvaluateWhenApplied();
protected:
Manager &m_mgr;
const TargetPhrase &m_targetPhrase;

View File

@ -89,6 +89,7 @@ void SearchNormal::Extend(const Hypothesis &hypo,
const Moses::Bitmap &newBitmap)
{
Hypothesis *newHypo = new (m_mgr.GetPool().Allocate<Hypothesis>()) Hypothesis(hypo, tp, pathRange, newBitmap);
newHypo->EvaluateWhenApplied();
size_t numWordsCovered = newBitmap.GetNumWordsCovered();
StackAdd stackAdded = m_stacks[numWordsCovered].Add(newHypo);