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();
|
|
|
|
}
|
|
|
|
|
2014-07-10 01:35:59 +04:00
|
|
|
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
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-10 02:06:54 +04:00
|
|
|
void SkeletonStatelessFF::EvaluateWithSourceContext(const InputType &input
|
2013-09-27 12:35:24 +04:00
|
|
|
, const InputPath &inputPath
|
|
|
|
, const TargetPhrase &targetPhrase
|
2014-05-08 20:51:45 +04:00
|
|
|
, const StackVec *stackVec
|
2013-12-03 19:50:41 +04:00
|
|
|
, 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
|
|
|
|
2015-01-06 15:56:13 +03:00
|
|
|
void SkeletonStatelessFF::EvaluateTranslationOptionListWithSourceContext(const InputType &input
|
|
|
|
|
|
|
|
, const TranslationOptionList &translationOptionList) const
|
2015-01-06 12:46:31 +03:00
|
|
|
{}
|
|
|
|
|
2014-07-10 02:41:08 +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
|
|
|
{}
|
|
|
|
|
2014-07-10 02:54:16 +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
|
|
|
}
|
|
|
|
|