mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-11-14 19:08:50 +03:00
stateful FF framework
This commit is contained in:
parent
d54de8c8db
commit
d58bbf158d
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user