mosesdecoder/moses/FF/ExampleStatefulFF.h

86 lines
2.8 KiB
C
Raw Permalink Normal View History

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
virtual size_t hash() const {
2015-10-16 15:53:33 +03:00
return (size_t) m_targetLen;
}
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;
}
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
// 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
// and the empty skeleton implementation from the corresponding .cpp
// file to reduce code clutter.
2015-11-20 03:00:42 +03:00
void
EvaluateInIsolation(const Phrase &source
2015-11-20 03:00:42 +03:00
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection &estimatedScores) const;
// 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
// and the empty skeleton implementation from the corresponding .cpp
// file to reduce code clutter.
2015-11-20 03:00:42 +03:00
void
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
// 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
// and the empty skeleton implementation from the corresponding .cpp
// file to reduce code clutter.
2015-11-20 03:00:42 +03:00
void
EvaluateTranslationOptionListWithSourceContext
( const InputType &input , const TranslationOptionList &translationOptionList) const;
2015-01-14 14:07:42 +03:00
FFState* EvaluateWhenApplied(
2013-09-27 12:35:24 +04:00
const Hypothesis& cur_hypo,
const FFState* prev_state,
ScoreComponentCollection* accumulator) const;
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
};
}