2013-09-01 19:58:23 +04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include "StatefulFeatureFunction.h"
|
|
|
|
#include "FFState.h"
|
|
|
|
|
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2017-04-26 15:10:32 +03:00
|
|
|
class ExampleState : public FFState
|
2013-09-01 19:58:23 +04:00
|
|
|
{
|
2013-09-27 12:35:24 +04:00
|
|
|
int m_targetLen;
|
2013-09-01 19:58:23 +04:00
|
|
|
public:
|
2017-04-26 15:10:32 +03:00
|
|
|
ExampleState(int targetLen)
|
2015-01-14 14:07:42 +03:00
|
|
|
:m_targetLen(targetLen) {
|
|
|
|
}
|
2013-09-25 23:19:05 +04:00
|
|
|
|
2015-10-08 19:14:08 +03:00
|
|
|
virtual size_t hash() const {
|
2015-10-16 15:53:33 +03:00
|
|
|
return (size_t) m_targetLen;
|
2015-10-08 19:14:08 +03:00
|
|
|
}
|
2015-10-16 15:53:33 +03:00
|
|
|
virtual bool operator==(const FFState& o) const {
|
2017-04-26 15:10:32 +03:00
|
|
|
const ExampleState& other = static_cast<const ExampleState&>(o);
|
2015-10-13 18:24:22 +03:00
|
|
|
return m_targetLen == other.m_targetLen;
|
2015-10-08 20:14:52 +03:00
|
|
|
}
|
2015-10-08 19:14:08 +03:00
|
|
|
|
2013-09-01 19:58:23 +04:00
|
|
|
};
|
|
|
|
|
2017-04-26 15:10:32 +03:00
|
|
|
class ExampleStatefulFF : public StatefulFeatureFunction
|
2013-09-01 19:58:23 +04:00
|
|
|
{
|
|
|
|
public:
|
2017-04-26 15:10:32 +03:00
|
|
|
ExampleStatefulFF(const std::string &line);
|
2013-09-27 12:35:24 +04:00
|
|
|
|
|
|
|
bool IsUseable(const FactorMask &mask) const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
virtual const FFState* EmptyHypothesisState(const InputType &input) const {
|
2017-04-26 15:10:32 +03:00
|
|
|
return new ExampleState(0);
|
2013-09-25 23:19:05 +04:00
|
|
|
}
|
2013-09-01 19:58:23 +04:00
|
|
|
|
2015-11-19 16:54:24 +03:00
|
|
|
// An empty implementation of this function is provided by StatefulFeatureFunction.
|
2015-11-20 03:00:42 +03:00
|
|
|
// Unless you are actually implementing this, please remove this declaration here
|
2015-11-19 16:54:24 +03:00
|
|
|
// and the empty skeleton implementation from the corresponding .cpp
|
|
|
|
// file to reduce code clutter.
|
2015-11-20 03:00:42 +03:00
|
|
|
void
|
2015-11-19 16:54:24 +03:00
|
|
|
EvaluateInIsolation(const Phrase &source
|
2015-11-20 03:00:42 +03:00
|
|
|
, const TargetPhrase &targetPhrase
|
|
|
|
, ScoreComponentCollection &scoreBreakdown
|
|
|
|
, ScoreComponentCollection &estimatedScores) const;
|
|
|
|
|
2015-11-19 16:54:24 +03:00
|
|
|
// An empty implementation of this function is provided by StatefulFeatureFunction.
|
2015-11-20 03:00:42 +03:00
|
|
|
// Unless you are actually implementing this, please remove this declaration here
|
2015-11-19 16:54:24 +03:00
|
|
|
// and the empty skeleton implementation from the corresponding .cpp
|
|
|
|
// file to reduce code clutter.
|
2015-11-20 03:00:42 +03:00
|
|
|
void
|
2015-11-19 16:54:24 +03:00
|
|
|
EvaluateWithSourceContext(const InputType &input
|
2015-11-20 03:00:42 +03:00
|
|
|
, const InputPath &inputPath
|
|
|
|
, const TargetPhrase &targetPhrase
|
|
|
|
, const StackVec *stackVec
|
|
|
|
, ScoreComponentCollection &scoreBreakdown
|
|
|
|
, ScoreComponentCollection *estimatedScores = NULL) const;
|
2015-01-14 14:07:42 +03:00
|
|
|
|
2015-11-19 16:54:24 +03:00
|
|
|
// An empty implementation of this function is provided by StatefulFeatureFunction.
|
2015-11-20 03:00:42 +03:00
|
|
|
// Unless you are actually implementing this, please remove this declaration here
|
2015-11-19 16:54:24 +03:00
|
|
|
// and the empty skeleton implementation from the corresponding .cpp
|
|
|
|
// file to reduce code clutter.
|
2015-11-20 03:00:42 +03:00
|
|
|
void
|
2015-11-19 16:54:24 +03:00
|
|
|
EvaluateTranslationOptionListWithSourceContext
|
|
|
|
( const InputType &input , const TranslationOptionList &translationOptionList) const;
|
2015-01-14 14:07:42 +03:00
|
|
|
|
2014-07-10 02:41:08 +04:00
|
|
|
FFState* EvaluateWhenApplied(
|
2013-09-27 12:35:24 +04:00
|
|
|
const Hypothesis& cur_hypo,
|
|
|
|
const FFState* prev_state,
|
|
|
|
ScoreComponentCollection* accumulator) const;
|
2014-07-10 02:54:16 +04:00
|
|
|
FFState* EvaluateWhenApplied(
|
2013-09-27 12:35:24 +04:00
|
|
|
const ChartHypothesis& /* cur_hypo */,
|
|
|
|
int /* featureID - used to index the state in the previous hypotheses */,
|
|
|
|
ScoreComponentCollection* accumulator) const;
|
2013-09-01 19:58:23 +04:00
|
|
|
|
2014-06-18 12:08:19 +04:00
|
|
|
void SetParameter(const std::string& key, const std::string& value);
|
|
|
|
|
2013-09-01 19:58:23 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|