Chart stateless ff interface only allows essential info.

Not tested
This commit is contained in:
Barry Haddow 2012-09-13 22:08:01 +01:00
parent 23b2204cc1
commit 96b5c2e633
15 changed files with 66 additions and 45 deletions

View File

@ -168,7 +168,8 @@ void ChartHypothesis::CalcScore()
m_manager.GetTranslationSystem()->GetStatelessFeatureFunctions();
for (unsigned i = 0; i < sfs.size(); ++i)
if (sfs[i]->ComputeValueInTranslationOption() == false)
sfs[i]->EvaluateChart(*this,i,&m_scoreBreakdown);
sfs[i]->EvaluateChart(GetCurrTargetPhrase(),
GetManager().GetSource(),GetCurrSourceRange(),&m_scoreBreakdown);
const std::vector<const StatefulFeatureFunction*>& ffs =
m_manager.GetTranslationSystem()->GetStatefulFeatureFunctions();

View File

@ -29,8 +29,8 @@ public:
ScoreComponentCollection* accumulator) const;
virtual FFState* EvaluateChart(
const ChartHypothesis&,
int /* featureID */,
const ChartHypothesis& /* cur_hypo */,
int /* featureID - used to index the state in the previous hypotheses */,
ScoreComponentCollection*) const {
CHECK(0); // feature function not valid in chart decoder
return NULL;
@ -54,11 +54,16 @@ public:
ScoreComponentCollection* accumulator) const;
virtual void EvaluateChart(
const ChartHypothesis&,
int /* featureID */,
ScoreComponentCollection*) const {
// needs to be implemented but does nothing
}
const TargetPhrase& targetPhrase,
const InputType& inputType,
const WordsRange& sourceSpan,
ScoreComponentCollection* accumulator) const
{
//required but does nothing.
}
};
/** unknown word penalty */
@ -79,8 +84,9 @@ public:
}
void EvaluateChart(
const ChartHypothesis& cur_hypo,
int featureID,
const TargetPhrase& targetPhrase,
const InputType& inputType,
const WordsRange& sourceSpan,
ScoreComponentCollection* accumulator) const
{
//do nothing - not a real feature

View File

@ -16,6 +16,7 @@ class FFState;
class InputType;
class ScoreComponentCollection;
class WordsBitmap;
class WordsRange;
/** base class for all feature functions.
* @todo is this for pb & hiero too?
@ -51,8 +52,9 @@ public:
const WordsBitmap& coverageVector,
ScoreComponentCollection* accumulator) const = 0;
virtual void EvaluateChart(const ChartHypothesis& cur_hypo,
int featureID,
virtual void EvaluateChart(const TargetPhrase& targetPhrase,
const InputType& inputType,
const WordsRange& sourceSpan,
ScoreComponentCollection* accumulator) const = 0;
//If true, then the feature is evaluated before search begins, and stored in

View File

@ -98,8 +98,9 @@ public:
throw std::runtime_error("GenerationDictionary::Evaluate() Not implemented");
}
virtual void EvaluateChart(const ChartHypothesis& cur_hypo,
int featureID,
virtual void EvaluateChart(const TargetPhrase& targetPhrase,
const InputType& inputType,
const WordsRange& sourceSpan,
ScoreComponentCollection* accumulator) const
{
throw std::runtime_error("GenerationDictionary.Evaluate() Not implemented");

View File

@ -81,8 +81,9 @@ public:
void EvaluateChart(
const ChartHypothesis& cur_hypo,
int featureID,
const TargetPhrase& targetPhrase,
const InputType& inputType,
const WordsRange& sourceSpan,
ScoreComponentCollection* accumulator) const
{
std::cerr << "EvaluateChart not implemented." << std::endl;

View File

@ -144,8 +144,9 @@ public:
throw std::runtime_error("PhraseDictionary.Evaluate() Not implemented");
}
virtual void EvaluateChart(const ChartHypothesis& cur_hypo,
int featureID,
virtual void EvaluateChart(const TargetPhrase& targetPhrase,
const InputType& inputType,
const WordsRange& sourceSpan,
ScoreComponentCollection* accumulator) const
{
throw std::runtime_error("PhraseDictionary.EvaluateChart() Not implemented");

View File

@ -25,10 +25,10 @@ public:
const WordsBitmap& coverageVector,
ScoreComponentCollection* accumulator) const;
void EvaluateChart(
const ChartHypothesis&,
int /* featureID */,
ScoreComponentCollection*) const {
void EvaluateChart(const TargetPhrase& targetPhrase,
const InputType& inputType,
const WordsRange& sourceSpan,
ScoreComponentCollection*) const {
CHECK(0); // feature function not valid in chart decoder
}

View File

@ -71,10 +71,10 @@ class PhrasePairFeature: public StatelessFeatureFunction {
const WordsBitmap& coverageVector,
ScoreComponentCollection* accumulator) const;
void EvaluateChart(
const ChartHypothesis&,
int /* featureID */,
ScoreComponentCollection*) const {
void EvaluateChart(const TargetPhrase& targetPhrase,
const InputType& inputType,
const WordsRange& sourceSpan,
ScoreComponentCollection*) const {
CHECK(0); // feature function not valid in chart decoder
}

View File

@ -43,10 +43,12 @@ void SourceWordDeletionFeature::Evaluate(
ComputeFeatures(targetPhrase, accumulator, alignment);
}
void SourceWordDeletionFeature::EvaluateChart(const ChartHypothesis& cur_hypo, int featureId,
ScoreComponentCollection* accumulator) const
void SourceWordDeletionFeature::EvaluateChart(
const TargetPhrase& targetPhrase,
const InputType& inputType,
const WordsRange& sourceSpan,
ScoreComponentCollection* accumulator) const
{
const TargetPhrase& targetPhrase = cur_hypo.GetCurrTargetPhrase();
const AlignmentInfo &alignmentInfo = targetPhrase.GetAlignmentInfo();
const AlignmentInfo::CollType &alignment = alignmentInfo.GetTerminalAlignments();
ComputeFeatures(targetPhrase, accumulator, alignment);

View File

@ -34,8 +34,9 @@ public:
const WordsBitmap& coverageVector,
ScoreComponentCollection* accumulator) const;
void EvaluateChart(const ChartHypothesis& cur_hypo,
int featureId,
void EvaluateChart(const TargetPhrase& targetPhrase,
const InputType& inputType,
const WordsRange& sourceSpan,
ScoreComponentCollection* accumulator) const;
void ComputeFeatures(const TargetPhrase& targetPhrase,

View File

@ -22,8 +22,9 @@ public:
ScoreComponentCollection* accumulator) const;
void EvaluateChart(
const ChartHypothesis&,
int /* featureID */,
const TargetPhrase& targetPhrase,
const InputType& inputType,
const WordsRange& sourceSpan,
ScoreComponentCollection*) const {
CHECK(0); // feature function not valid in chart decoder
}

View File

@ -43,11 +43,12 @@ void TargetWordInsertionFeature::Evaluate(
ComputeFeatures(targetPhrase, accumulator, alignment);
}
void TargetWordInsertionFeature::EvaluateChart(const ChartHypothesis& cur_hypo,
int featureID,
ScoreComponentCollection* accumulator) const
void TargetWordInsertionFeature::EvaluateChart(
const TargetPhrase& targetPhrase,
const InputType& inputType,
const WordsRange& sourceSpan,
ScoreComponentCollection* accumulator) const
{
const TargetPhrase& targetPhrase = cur_hypo.GetCurrTargetPhrase();
const AlignmentInfo &alignmentInfo = targetPhrase.GetAlignmentInfo();
const AlignmentInfo::CollType &alignment = alignmentInfo.GetTerminalAlignments();
ComputeFeatures(targetPhrase, accumulator, alignment);

View File

@ -35,9 +35,10 @@ public:
ScoreComponentCollection* accumulator) const;
void EvaluateChart(
const ChartHypothesis& cur_hypo,
int featureID,
ScoreComponentCollection* accumulator) const;
const TargetPhrase& targetPhrase,
const InputType& inputType,
const WordsRange& sourceSpan,
ScoreComponentCollection* accumulator) const;
void ComputeFeatures(const TargetPhrase& targetPhrase,
ScoreComponentCollection* accumulator,

View File

@ -197,11 +197,13 @@ void WordTranslationFeature::Evaluate
}
}
void WordTranslationFeature::EvaluateChart(const ChartHypothesis& cur_hypo, int featureID,
ScoreComponentCollection* accumulator) const
void WordTranslationFeature::EvaluateChart(
const TargetPhrase& targetPhrase,
const InputType& inputType,
const WordsRange& sourceSpan,
ScoreComponentCollection* accumulator) const
{
//const Sentence& input = *(m_local->input);
const TargetPhrase& targetPhrase = cur_hypo.GetCurrTargetPhrase();
const AlignmentInfo &alignmentInfo = targetPhrase.GetAlignmentInfo();
const AlignmentInfo::CollType &alignment = alignmentInfo.GetTerminalAlignments();

View File

@ -93,8 +93,9 @@ public:
const WordsBitmap& coverageVector,
ScoreComponentCollection* accumulator) const;
void EvaluateChart(const ChartHypothesis& cur_hypo,
int featureID,
void EvaluateChart(const TargetPhrase& targetPhrase,
const InputType& inputType,
const WordsRange& sourceSpan,
ScoreComponentCollection* accumulator) const;
// basic properties