mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-01 16:33:16 +03:00
FF framework
This commit is contained in:
parent
d32b3f5968
commit
3f05ea5e6c
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
};
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user