mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 05:14:36 +03:00
put some meat onto skeleton FFs
This commit is contained in:
parent
1758381c98
commit
56c1224c28
@ -1,7 +1,59 @@
|
||||
#include <vector>
|
||||
#include "SkeletonStatefulFF.h"
|
||||
#include "moses/ScoreComponentCollection.h"
|
||||
#include "moses/Hypothesis.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
int SkeletonState::Compare(const FFState& other) const
|
||||
{
|
||||
const SkeletonState &otherState = static_cast<const SkeletonState&>(other);
|
||||
|
||||
if (m_targetLen == otherState.m_targetLen)
|
||||
return 0;
|
||||
return (m_targetLen < otherState.m_targetLen) ? -1 : +1;
|
||||
}
|
||||
|
||||
void SkeletonStatefulFF::Evaluate(const Phrase &source
|
||||
, const TargetPhrase &targetPhrase
|
||||
, ScoreComponentCollection &scoreBreakdown
|
||||
, ScoreComponentCollection &estimatedFutureScore) const
|
||||
{}
|
||||
|
||||
void SkeletonStatefulFF::Evaluate(const InputType &input
|
||||
, const InputPath &inputPath
|
||||
, const TargetPhrase &targetPhrase
|
||||
, ScoreComponentCollection &scoreBreakdown) const
|
||||
{}
|
||||
|
||||
FFState* SkeletonStatefulFF::Evaluate(
|
||||
const Hypothesis& cur_hypo,
|
||||
const FFState* prev_state,
|
||||
ScoreComponentCollection* accumulator) const
|
||||
{
|
||||
// dense scores
|
||||
vector<float> newScores(m_numScoreComponents);
|
||||
newScores[0] = 1.5;
|
||||
newScores[1] = 0.3;
|
||||
newScores[2] = 0.4;
|
||||
accumulator->PlusEquals(this, newScores);
|
||||
|
||||
// sparse scores
|
||||
accumulator->PlusEquals(this, "sparse-name", 2.4);
|
||||
|
||||
int targetLen = cur_hypo.GetCurrTargetPhrase().GetSize();
|
||||
return new SkeletonState(0);
|
||||
}
|
||||
|
||||
FFState* SkeletonStatefulFF::EvaluateChart(
|
||||
const ChartHypothesis& /* cur_hypo */,
|
||||
int /* featureID - used to index the state in the previous hypotheses */,
|
||||
ScoreComponentCollection* accumulator) const
|
||||
{
|
||||
return new SkeletonState(0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -9,54 +9,45 @@ namespace Moses
|
||||
|
||||
class SkeletonState : public FFState
|
||||
{
|
||||
int m_targetLen;
|
||||
public:
|
||||
int Compare(const FFState& other) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
SkeletonState(int targetLen)
|
||||
:m_targetLen(targetLen)
|
||||
{}
|
||||
|
||||
int Compare(const FFState& other) const;
|
||||
};
|
||||
|
||||
class SkeletonStatefulFF : public StatefulFeatureFunction
|
||||
{
|
||||
public:
|
||||
SkeletonStatefulFF(const std::string &line)
|
||||
:StatefulFeatureFunction("StatefulFeatureFunction", line)
|
||||
:StatefulFeatureFunction("SkeletonStatefulFF", 3, line)
|
||||
{}
|
||||
|
||||
bool IsUseable(const FactorMask &mask) const
|
||||
{ return true; }
|
||||
virtual const FFState* EmptyHypothesisState(const InputType &input) const
|
||||
{
|
||||
return new SkeletonState(0);
|
||||
}
|
||||
|
||||
void Evaluate(const Phrase &source
|
||||
, const TargetPhrase &targetPhrase
|
||||
, ScoreComponentCollection &scoreBreakdown
|
||||
, ScoreComponentCollection &estimatedFutureScore) const
|
||||
{}
|
||||
, ScoreComponentCollection &estimatedFutureScore) const;
|
||||
void Evaluate(const InputType &input
|
||||
, const InputPath &inputPath
|
||||
, const TargetPhrase &targetPhrase
|
||||
, ScoreComponentCollection &scoreBreakdown) const
|
||||
{}
|
||||
, ScoreComponentCollection &scoreBreakdown) const;
|
||||
FFState* Evaluate(
|
||||
const Hypothesis& cur_hypo,
|
||||
const FFState* prev_state,
|
||||
ScoreComponentCollection* accumulator) const
|
||||
{
|
||||
return new SkeletonState();
|
||||
}
|
||||
|
||||
ScoreComponentCollection* accumulator) const;
|
||||
FFState* EvaluateChart(
|
||||
const ChartHypothesis& /* cur_hypo */,
|
||||
int /* featureID - used to index the state in the previous hypotheses */,
|
||||
ScoreComponentCollection* accumulator) const
|
||||
{
|
||||
return new SkeletonState();
|
||||
}
|
||||
|
||||
virtual const FFState* EmptyHypothesisState(const InputType &input) const
|
||||
{
|
||||
return new SkeletonState();
|
||||
}
|
||||
|
||||
ScoreComponentCollection* accumulator) const;
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,40 @@
|
||||
#include "SkeletonStatelessFF.h"
|
||||
#include "moses/ScoreComponentCollection.h"
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
void SkeletonStatelessFF::Evaluate(const Phrase &source
|
||||
, const TargetPhrase &targetPhrase
|
||||
, ScoreComponentCollection &scoreBreakdown
|
||||
, ScoreComponentCollection &estimatedFutureScore) const
|
||||
{
|
||||
// dense scores
|
||||
vector<float> newScores(m_numScoreComponents);
|
||||
newScores[0] = 1.5;
|
||||
newScores[1] = 0.3;
|
||||
scoreBreakdown.PlusEquals(this, newScores);
|
||||
|
||||
// sparse scores
|
||||
scoreBreakdown.PlusEquals(this, "sparse-name", 2.4);
|
||||
|
||||
}
|
||||
|
||||
void SkeletonStatelessFF::Evaluate(const InputType &input
|
||||
, const InputPath &inputPath
|
||||
, const TargetPhrase &targetPhrase
|
||||
, ScoreComponentCollection &scoreBreakdown) const
|
||||
{}
|
||||
|
||||
void SkeletonStatelessFF::Evaluate(const Hypothesis& hypo,
|
||||
ScoreComponentCollection* accumulator) const
|
||||
{}
|
||||
|
||||
void SkeletonStatelessFF::EvaluateChart(const ChartHypothesis &hypo,
|
||||
ScoreComponentCollection* accumulator) const
|
||||
{}
|
||||
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ class SkeletonStatelessFF : public StatelessFeatureFunction
|
||||
{
|
||||
public:
|
||||
SkeletonStatelessFF(const std::string &line)
|
||||
:StatelessFeatureFunction("SkeletonStatelessFF", line)
|
||||
:StatelessFeatureFunction("SkeletonStatelessFF", 2, line)
|
||||
{}
|
||||
|
||||
bool IsUseable(const FactorMask &mask) const
|
||||
@ -19,19 +19,15 @@ public:
|
||||
void Evaluate(const Phrase &source
|
||||
, const TargetPhrase &targetPhrase
|
||||
, ScoreComponentCollection &scoreBreakdown
|
||||
, ScoreComponentCollection &estimatedFutureScore) const
|
||||
{}
|
||||
, ScoreComponentCollection &estimatedFutureScore) const;
|
||||
void Evaluate(const InputType &input
|
||||
, const InputPath &inputPath
|
||||
, const TargetPhrase &targetPhrase
|
||||
, ScoreComponentCollection &scoreBreakdown) const
|
||||
{}
|
||||
virtual void Evaluate(const Hypothesis& hypo,
|
||||
ScoreComponentCollection* accumulator) const
|
||||
{}
|
||||
, ScoreComponentCollection &scoreBreakdown) const;
|
||||
void Evaluate(const Hypothesis& hypo,
|
||||
ScoreComponentCollection* accumulator) const;
|
||||
void EvaluateChart(const ChartHypothesis &hypo,
|
||||
ScoreComponentCollection* accumulator) const
|
||||
{}
|
||||
ScoreComponentCollection* accumulator) const;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user