2013-07-21 02:10:50 +04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include "StatefulFeatureFunction.h"
|
|
|
|
#include "moses/FF/FFState.h"
|
|
|
|
|
2013-07-25 18:23:05 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
2013-07-21 02:10:50 +04:00
|
|
|
|
|
|
|
class ControlRecombinationState;
|
|
|
|
|
|
|
|
// force hypotheses NOT to recombine. For forced decoding
|
|
|
|
class ControlRecombination : public StatefulFeatureFunction
|
|
|
|
{
|
|
|
|
public:
|
2013-07-25 18:23:05 +04:00
|
|
|
enum Type {
|
|
|
|
None,
|
|
|
|
Output,
|
|
|
|
Segmentation
|
|
|
|
};
|
2013-07-21 02:41:49 +04:00
|
|
|
|
2013-07-21 02:10:50 +04:00
|
|
|
ControlRecombination(const std::string &line);
|
|
|
|
|
|
|
|
bool IsUseable(const FactorMask &mask) const {
|
2013-07-25 18:23:05 +04:00
|
|
|
return true;
|
2013-07-21 02:10:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual FFState* Evaluate(
|
|
|
|
const Hypothesis& cur_hypo,
|
|
|
|
const FFState* prev_state,
|
|
|
|
ScoreComponentCollection* accumulator) const;
|
|
|
|
|
|
|
|
virtual FFState* EvaluateChart(
|
|
|
|
const ChartHypothesis& /* cur_hypo */,
|
|
|
|
int /* featureID - used to index the state in the previous hypotheses */,
|
|
|
|
ScoreComponentCollection* accumulator) const;
|
|
|
|
|
|
|
|
//! return the state associated with the empty hypothesis for a given sentence
|
|
|
|
virtual const FFState* EmptyHypothesisState(const InputType &input) const;
|
|
|
|
|
2013-07-21 02:41:49 +04:00
|
|
|
void SetParameter(const std::string& key, const std::string& value);
|
|
|
|
protected:
|
|
|
|
Type m_type;
|
2013-07-21 02:10:50 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class ControlRecombinationState : public FFState
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
const Hypothesis *m_hypo;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ControlRecombinationState();
|
|
|
|
ControlRecombinationState(const Hypothesis *hypo);
|
|
|
|
int Compare(const FFState& other) const;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|