FF framework

This commit is contained in:
Hieu Hoang 2015-10-29 00:47:06 +00:00
parent d32b3f5968
commit 3f05ea5e6c
14 changed files with 56 additions and 35 deletions

View File

@ -37,10 +37,10 @@ public:
// For SCFG decoding, the source contains non-terminals, NOT the raw
// source from the input sentence
virtual void
EvaluateInIsolation(const Manager &mgr,
EvaluateInIsolation(const System &system,
const Phrase &source, const TargetPhrase &targetPhrase,
Scores& scores,
Scores& estimatedFutureScores) const = 0;
Scores &scores,
Scores *estimatedFutureScores) const = 0;
protected:
size_t m_startInd;

View File

@ -119,3 +119,14 @@ const FeatureFunction &FeatureFunctions::FindFeatureFunction(const std::string &
}
void
FeatureFunctions::EvaluateInIsolation(const System &system,
const Phrase &source, const TargetPhrase &targetPhrase,
Scores& scores,
Scores *estimatedFutureScores) const
{
BOOST_FOREACH(const FeatureFunction *ff, m_featureFunctions) {
ff->EvaluateInIsolation(system, source, targetPhrase, scores, estimatedFutureScores);
}
}

View File

@ -16,6 +16,10 @@ class System;
class FeatureFunction;
class StatefulFeatureFunction;
class PhraseTable;
class Manager;
class Phrase;
class TargetPhrase;
class Scores;
class FeatureFunctions {
public:
@ -35,6 +39,12 @@ public:
const FeatureFunction &FindFeatureFunction(const std::string &name);
virtual void
EvaluateInIsolation(const System &system,
const Phrase &source, const TargetPhrase &targetPhrase,
Scores &scores,
Scores *estimatedFutureScores) const;
protected:
std::vector<const FeatureFunction*> m_featureFunctions;
std::vector<const StatefulFeatureFunction*> m_statefulFeatureFunctions;

View File

@ -61,10 +61,10 @@ TargetPhrases::shared_const_ptr PhraseTable::Lookup(const Manager &mgr, InputPat
}
void
PhraseTable::EvaluateInIsolation(const Manager &mgr,
PhraseTable::EvaluateInIsolation(const System &system,
const Phrase &source, const TargetPhrase &targetPhrase,
Scores& scores,
Scores& estimatedFutureScores) const
Scores &scores,
Scores *estimatedFutureScores) const
{
}

View File

@ -34,10 +34,10 @@ public:
{ return m_ptInd; }
virtual void
EvaluateInIsolation(const Manager &mgr,
EvaluateInIsolation(const System &system,
const Phrase &source, const TargetPhrase &targetPhrase,
Scores& scores,
Scores& estimatedFutureScores) const;
Scores &scores,
Scores *estimatedFutureScores) const;
protected:
std::string m_path;

View File

@ -101,6 +101,7 @@ void PhraseTableMemory::Load(System &system)
target->GetScores().CreateFromString(toks[2], *this, system);
//cerr << "created scores" << endl;
//system.GetFeatureFunctions().EvaluateInIsolation()
m_root.AddRule(*source, target);
}
}

View File

@ -18,10 +18,10 @@ SkeletonStatefulFF::~SkeletonStatefulFF() {
}
void
SkeletonStatefulFF::EvaluateInIsolation(const Manager &mgr,
SkeletonStatefulFF::EvaluateInIsolation(const System &system,
const Phrase &source, const TargetPhrase &targetPhrase,
Scores& scores,
Scores& estimatedFutureScores) const
Scores &scores,
Scores *estimatedFutureScores) const
{
}

View File

@ -17,10 +17,10 @@ public:
virtual ~SkeletonStatefulFF();
virtual void
EvaluateInIsolation(const Manager &mgr,
EvaluateInIsolation(const System &system,
const Phrase &source, const TargetPhrase &targetPhrase,
Scores& scores,
Scores& estimatedFutureScores) const;
Scores &scores,
Scores *estimatedFutureScores) const;
};

View File

@ -18,10 +18,10 @@ SkeletonStatelessFF::~SkeletonStatelessFF() {
}
void
SkeletonStatelessFF::EvaluateInIsolation(const Manager &mgr,
SkeletonStatelessFF::EvaluateInIsolation(const System &system,
const Phrase &source, const TargetPhrase &targetPhrase,
Scores& scores,
Scores& estimatedFutureScores) const
Scores &scores,
Scores *estimatedFutureScores) const
{
}

View File

@ -16,9 +16,9 @@ public:
virtual ~SkeletonStatelessFF();
virtual void
EvaluateInIsolation(const Manager &mgr,
EvaluateInIsolation(const System &system,
const Phrase &source, const TargetPhrase &targetPhrase,
Scores& scores,
Scores& estimatedFutureScores) const;
Scores &scores,
Scores *estimatedFutureScores) const;
};

View File

@ -53,10 +53,10 @@ TargetPhrases::shared_const_ptr UnknownWordPenalty::Lookup(const Manager &mgr, I
}
void
UnknownWordPenalty::EvaluateInIsolation(const Manager &mgr,
UnknownWordPenalty::EvaluateInIsolation(const System &system,
const Phrase &source, const TargetPhrase &targetPhrase,
Scores& scores,
Scores& estimatedFutureScores) const
Scores &scores,
Scores *estimatedFutureScores) const
{
}

View File

@ -19,10 +19,10 @@ public:
virtual TargetPhrases::shared_const_ptr Lookup(const Manager &mgr, InputPath &inputPath) const;
virtual void
EvaluateInIsolation(const Manager &mgr,
EvaluateInIsolation(const System &system,
const Phrase &source, const TargetPhrase &targetPhrase,
Scores& scores,
Scores& estimatedFutureScores) const;
Scores &scores,
Scores *estimatedFutureScores) const;
};

View File

@ -22,15 +22,14 @@ WordPenalty::~WordPenalty() {
}
void
WordPenalty::EvaluateInIsolation(const Manager &mgr,
WordPenalty::EvaluateInIsolation(const System &system,
const Phrase &source,
const TargetPhrase &targetPhrase,
Scores& scores,
Scores& estimatedFutureScores) const
Scores &scores,
Scores *estimatedFutureScores) const
{
SCORE score = - (SCORE) targetPhrase.GetSize();
scores.PlusEquals(mgr.GetSystem(), *this, score);
scores.PlusEquals(system, *this, score);
}

View File

@ -17,11 +17,11 @@ public:
virtual ~WordPenalty();
virtual void
EvaluateInIsolation(const Manager &mgr,
EvaluateInIsolation(const System &system,
const Phrase &source,
const TargetPhrase &targetPhrase,
Scores& scores,
Scores& estimatedFutureScores) const;
Scores &scores,
Scores *estimatedFutureScores) const;
};