mosesdecoder/moses/FF/SkeletonStatelessFF.cpp

66 lines
2.0 KiB
C++
Raw Normal View History

2014-06-14 07:22:03 +04:00
#include <vector>
2013-09-01 19:58:23 +04:00
#include "SkeletonStatelessFF.h"
2013-09-25 23:19:05 +04:00
#include "moses/ScoreComponentCollection.h"
2014-06-14 07:22:03 +04:00
#include "moses/TargetPhrase.h"
2013-09-25 23:19:05 +04:00
using namespace std;
2013-09-01 19:58:23 +04:00
namespace Moses
{
2014-06-16 03:55:36 +04:00
SkeletonStatelessFF::SkeletonStatelessFF(const std::string &line)
:StatelessFeatureFunction(2, line)
{
ReadParameters();
}
void SkeletonStatelessFF::EvaluateInIsolation(const Phrase &source
2013-09-27 12:35:24 +04:00
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection &estimatedFutureScore) const
2013-09-25 23:19:05 +04:00
{
2013-09-27 12:35:24 +04:00
// dense scores
vector<float> newScores(m_numScoreComponents);
newScores[0] = 1.5;
newScores[1] = 0.3;
scoreBreakdown.PlusEquals(this, newScores);
2013-09-25 23:19:05 +04:00
2013-09-27 12:35:24 +04:00
// sparse scores
scoreBreakdown.PlusEquals(this, "sparse-name", 2.4);
2013-09-25 23:19:05 +04:00
}
void SkeletonStatelessFF::EvaluateWithSourceContext(const InputType &input
2013-09-27 12:35:24 +04:00
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, const StackVec *stackVec
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore) const
2014-06-14 07:22:03 +04:00
{
if (targetPhrase.GetNumNonTerminals()) {
vector<float> newScores(m_numScoreComponents);
newScores[0] = - std::numeric_limits<float>::infinity();
scoreBreakdown.PlusEquals(this, newScores);
}
}
2013-09-25 23:19:05 +04:00
void SkeletonStatelessFF::EvaluateWhenApplied(const Hypothesis& hypo,
2013-09-27 12:35:24 +04:00
ScoreComponentCollection* accumulator) const
2013-09-25 23:19:05 +04:00
{}
void SkeletonStatelessFF::EvaluateWhenApplied(const ChartHypothesis &hypo,
2013-09-27 12:35:24 +04:00
ScoreComponentCollection* accumulator) const
2013-09-25 23:19:05 +04:00
{}
2013-09-01 19:58:23 +04:00
2014-06-18 12:08:19 +04:00
void SkeletonStatelessFF::SetParameter(const std::string& key, const std::string& value)
{
if (key == "arg") {
// set value here
} else {
StatelessFeatureFunction::SetParameter(key, value);
}
}
2013-09-01 19:58:23 +04:00
}