2013-07-21 02:10:50 +04:00
|
|
|
#include "ControlRecombination.h"
|
|
|
|
#include "moses/Hypothesis.h"
|
|
|
|
#include "util/exception.hh"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2013-07-25 18:23:05 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
2013-07-21 02:10:50 +04:00
|
|
|
|
|
|
|
ControlRecombination::ControlRecombination(const std::string &line)
|
2013-07-25 18:23:05 +04:00
|
|
|
:StatefulFeatureFunction("ControlRecombination", 0, line)
|
|
|
|
,m_type(Output)
|
2013-07-21 02:10:50 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-07-21 02:41:49 +04:00
|
|
|
void ControlRecombination::SetParameter(const std::string& key, const std::string& value)
|
|
|
|
{
|
|
|
|
if (key == "type") {
|
|
|
|
m_type = (Type) Scan<size_t>(value);
|
|
|
|
} else {
|
|
|
|
StatefulFeatureFunction::SetParameter(key, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-21 02:10:50 +04:00
|
|
|
FFState* ControlRecombination::Evaluate(
|
|
|
|
const Hypothesis& cur_hypo,
|
|
|
|
const FFState* prev_state,
|
|
|
|
ScoreComponentCollection* accumulator) const
|
|
|
|
{
|
|
|
|
ControlRecombinationState *state = new ControlRecombinationState(&cur_hypo);
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
FFState* ControlRecombination::EvaluateChart(
|
|
|
|
const ChartHypothesis& /* cur_hypo */,
|
|
|
|
int /* featureID - used to index the state in the previous hypotheses */,
|
|
|
|
ScoreComponentCollection* accumulator) const
|
|
|
|
{
|
|
|
|
UTIL_THROW(util::Exception, "Not implemented yet");
|
|
|
|
}
|
|
|
|
|
|
|
|
const FFState* ControlRecombination::EmptyHypothesisState(const InputType &input) const
|
|
|
|
{
|
|
|
|
ControlRecombinationState *state = new ControlRecombinationState();
|
|
|
|
}
|
|
|
|
|
|
|
|
ControlRecombinationState::ControlRecombinationState()
|
2013-07-25 18:23:05 +04:00
|
|
|
:m_hypo(NULL)
|
2013-07-21 02:10:50 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ControlRecombinationState::ControlRecombinationState(const Hypothesis *hypo)
|
2013-07-25 18:23:05 +04:00
|
|
|
:m_hypo(hypo)
|
2013-07-21 02:10:50 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int ControlRecombinationState::Compare(const FFState& other) const
|
|
|
|
{
|
|
|
|
const ControlRecombinationState &other2 = static_cast<const ControlRecombinationState&>(other);
|
|
|
|
const Hypothesis *otherHypo = other2.m_hypo;
|
|
|
|
|
2013-07-23 04:38:08 +04:00
|
|
|
Phrase thisOutputPhrase, otherOutputPhrase;
|
2013-07-23 04:32:25 +04:00
|
|
|
m_hypo->GetOutputPhrase(thisOutputPhrase);
|
|
|
|
otherHypo->GetOutputPhrase(otherOutputPhrase);
|
2013-07-21 02:10:50 +04:00
|
|
|
|
2013-07-23 04:32:25 +04:00
|
|
|
int ret = thisOutputPhrase.Compare(otherOutputPhrase);
|
|
|
|
return ret;
|
2013-07-21 02:10:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|