revert changes to Distortion FF

This commit is contained in:
Hieu Hoang 2017-01-03 11:06:26 +00:00
parent ff12a13eaa
commit 02772c07de
2 changed files with 7 additions and 34 deletions

View File

@ -57,7 +57,6 @@ struct DistortionState_traditional: public FFState
Distortion::Distortion(size_t startInd, const std::string &line) :
StatefulFeatureFunction(startInd, line)
{
m_completedHypo = false;
ReadParameters();
}
@ -66,16 +65,6 @@ Distortion::~Distortion()
// TODO Auto-generated destructor stub
}
void Distortion::SetParameter(const std::string& key, const std::string& value)
{
if (key == "completed-hypo") {
m_completedHypo = Scan<bool>(value);
}
else {
StatefulFeatureFunction::SetParameter(key, value);
}
}
FFState* Distortion::BlankState(MemPool &pool, const System &sys) const
{
return new (pool.Allocate<DistortionState_traditional>()) DistortionState_traditional();
@ -121,7 +110,7 @@ void Distortion::EvaluateWhenApplied(const ManagerBase &mgr,
const DistortionState_traditional &prev =
static_cast<const DistortionState_traditional&>(prevState);
SCORE distortionScore = CalculateDistortionScore(prev.range,
hypo.GetInputPath().range, prev.first_gap, hypo.GetBitmap());
hypo.GetInputPath().range, prev.first_gap);
//cerr << "distortionScore=" << distortionScore << endl;
scores.PlusEquals(mgr.system, *this, distortionScore);
@ -134,11 +123,11 @@ void Distortion::EvaluateWhenApplied(const ManagerBase &mgr,
}
SCORE Distortion::CalculateDistortionScore(const Range &prev, const Range &curr,
const int FirstGap, const Bitmap &coverage) const
const int FirstGap) const
{
bool useEarlyDistortionCost = false;
if (!useEarlyDistortionCost) {
return -(SCORE) ComputeDistortionDistance(prev, curr, coverage);
return -(SCORE) ComputeDistortionDistance(prev, curr);
}
else {
/* Pay distortion score as soon as possible, from Moore and Quirk MT Summit 2007
@ -179,7 +168,7 @@ SCORE Distortion::CalculateDistortionScore(const Range &prev, const Range &curr,
}
int Distortion::ComputeDistortionDistance(const Range& prev,
const Range& current, const Bitmap &coverage) const
const Range& current) const
{
int dist = 0;
if (prev.GetNumWordsCovered() == 0) {
@ -187,18 +176,8 @@ int Distortion::ComputeDistortionDistance(const Range& prev,
}
else {
dist = (int) prev.GetEndPos() - (int) current.GetStartPos() + 1;
dist = abs(dist);
if (m_completedHypo && coverage.IsComplete()) {
dist += coverage.GetSize() - current.GetEndPos() - 1;
/*
cerr << "completed=" << coverage << " " << coverage.GetSize() << " "
<< prev << " "
<< current << " " << dist << endl;
*/
}
}
return dist;
return abs(dist);
}
void Distortion::EvaluateWhenApplied(const SCFG::Manager &mgr,
@ -209,4 +188,3 @@ void Distortion::EvaluateWhenApplied(const SCFG::Manager &mgr,
}
}

View File

@ -14,7 +14,6 @@
namespace Moses2
{
class Bitmap;
class Distortion: public StatefulFeatureFunction
{
@ -22,8 +21,6 @@ public:
Distortion(size_t startInd, const std::string &line);
virtual ~Distortion();
virtual void SetParameter(const std::string& key, const std::string& value);
virtual FFState* BlankState(MemPool &pool, const System &sys) const;
virtual void EmptyHypothesisState(FFState &state, const ManagerBase &mgr,
const InputType &input, const Hypothesis &hypo) const;
@ -51,12 +48,10 @@ public:
FFState &state) const;
protected:
bool m_completedHypo;
SCORE CalculateDistortionScore(const Range &prev, const Range &curr,
const int FirstGap, const Bitmap &coverage) const;
const int FirstGap) const;
int ComputeDistortionDistance(const Range& prev, const Range& current, const Bitmap &coverage) const;
int ComputeDistortionDistance(const Range& prev, const Range& current) const;
};