modified FF interface: Evaluate() with input has access to future-cost estimation

This commit is contained in:
Ales Tamchyna 2013-12-03 16:50:41 +01:00
parent fec97d2073
commit cd63f30f15
35 changed files with 73 additions and 34 deletions

View File

@ -124,7 +124,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
void Evaluate(const Phrase &source
, const TargetPhrase &targetPhrase

View File

@ -54,7 +54,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
FFState* Evaluate(
const Hypothesis& cur_hypo,

View File

@ -65,7 +65,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
FFState* Evaluate(
const Hypothesis& cur_hypo,

View File

@ -49,7 +49,8 @@ void CoveredReferenceFeature::Evaluate(const Phrase &source
void CoveredReferenceFeature::Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore) const
{}
void CoveredReferenceFeature::Load() {

View File

@ -59,7 +59,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const;
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const;
FFState* Evaluate(
const Hypothesis& cur_hypo,
const FFState* prev_state,

View File

@ -69,7 +69,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
void Evaluate(const Phrase &source
, const TargetPhrase &targetPhrase

View File

@ -43,7 +43,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
void Evaluate(const Phrase &source
, const TargetPhrase &targetPhrase

View File

@ -59,7 +59,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
FFState* Evaluate(
const Hypothesis& cur_hypo,

View File

@ -105,10 +105,12 @@ public:
// just before search.
// 'inputPath' is guaranteed to be the raw substring from the input. No factors were added or taken away
// Currently not used by any FF. Not called by moses_chart
// No FF should set estimatedFutureScore in both overloads!
virtual void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const = 0;
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const = 0;
virtual void SetParameter(const std::string& key, const std::string& value);
virtual void ReadParameters();

View File

@ -83,7 +83,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
void Evaluate(const Phrase &source
, const TargetPhrase &targetPhrase

View File

@ -93,7 +93,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
void Evaluate(const Phrase &source
, const TargetPhrase &targetPhrase

View File

@ -39,7 +39,8 @@ void InputFeature::SetParameter(const std::string& key, const std::string& value
void InputFeature::Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore) const
{
if (m_legacy) {
//binary phrase-table does input feature itself

View File

@ -40,7 +40,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const;
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const;
void Evaluate(const Hypothesis& hypo,
ScoreComponentCollection* accumulator) const

View File

@ -18,7 +18,8 @@ void InternalStructStatelessFF::Evaluate(const Phrase &source
void InternalStructStatelessFF::Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore) const
{
cerr << "HHHHH" << scoreBreakdown << endl;

View File

@ -24,7 +24,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const;
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const;
virtual void Evaluate(const Hypothesis& hypo,
ScoreComponentCollection* accumulator) const
{}

View File

@ -54,7 +54,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
void Evaluate(const Phrase &source
, const TargetPhrase &targetPhrase

View File

@ -41,7 +41,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
void Evaluate(const Phrase &source
, const TargetPhrase &targetPhrase

View File

@ -56,7 +56,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
void Evaluate(const Phrase &source
, const TargetPhrase &targetPhrase

View File

@ -36,7 +36,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
virtual void Evaluate(const Phrase &source

View File

@ -48,7 +48,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
void Evaluate(const Phrase &source
, const TargetPhrase &targetPhrase

View File

@ -29,7 +29,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
};

View File

@ -25,7 +25,8 @@ void SkeletonStatefulFF::Evaluate(const Phrase &source
void SkeletonStatefulFF::Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore) const
{}
FFState* SkeletonStatefulFF::Evaluate(

View File

@ -39,7 +39,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const;
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const;
FFState* Evaluate(
const Hypothesis& cur_hypo,
const FFState* prev_state,

View File

@ -25,7 +25,8 @@ void SkeletonStatelessFF::Evaluate(const Phrase &source
void SkeletonStatelessFF::Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore) const
{}
void SkeletonStatelessFF::Evaluate(const Hypothesis& hypo,

View File

@ -24,7 +24,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const;
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const;
void Evaluate(const Hypothesis& hypo,
ScoreComponentCollection* accumulator) const;
void EvaluateChart(const ChartHypothesis &hypo,

View File

@ -35,7 +35,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
void Evaluate(const Hypothesis& hypo,
ScoreComponentCollection* accumulator) const

View File

@ -50,7 +50,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
void Evaluate(const Phrase &source
, const TargetPhrase &targetPhrase

View File

@ -195,7 +195,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
void Evaluate(const Phrase &source
, const TargetPhrase &targetPhrase

View File

@ -35,7 +35,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
void Evaluate(const Hypothesis& hypo,
ScoreComponentCollection* accumulator) const

View File

@ -30,7 +30,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
void Evaluate(const Phrase &source
, const TargetPhrase &targetPhrase

View File

@ -30,7 +30,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
};

View File

@ -56,7 +56,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
void Evaluate(const Phrase &source
, const TargetPhrase &targetPhrase

View File

@ -94,7 +94,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore = NULL) const
{}
};

View File

@ -39,7 +39,8 @@ public:
void Evaluate(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown) const
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore) const
{}
void Evaluate(const Phrase &source
, const TargetPhrase &targetPhrase

View File

@ -142,12 +142,16 @@ void TargetPhrase::Evaluate(const InputType &input, const InputPath &inputPath)
{
const std::vector<FeatureFunction*> &ffs = FeatureFunction::GetFeatureFunctions();
const StaticData &staticData = StaticData::Instance();
ScoreComponentCollection futureScoreBreakdown;
for (size_t i = 0; i < ffs.size(); ++i) {
const FeatureFunction &ff = *ffs[i];
if (! staticData.IsFeatureFunctionIgnored( ff )) {
ff.Evaluate(input, inputPath, *this, m_scoreBreakdown);
}
}
float weightedScore = m_scoreBreakdown.GetWeightedScore();
m_futureScore += futureScoreBreakdown.GetWeightedScore();
m_fullScore = weightedScore + m_futureScore;
}
void TargetPhrase::SetXMLScore(float score)