From 02772c07dec22acb1d50397651ad189b0f97e1e6 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Tue, 3 Jan 2017 11:06:26 +0000 Subject: [PATCH] revert changes to Distortion FF --- contrib/moses2/FF/Distortion.cpp | 32 +++++--------------------------- contrib/moses2/FF/Distortion.h | 9 ++------- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/contrib/moses2/FF/Distortion.cpp b/contrib/moses2/FF/Distortion.cpp index 9e55ff798..1d7b7246d 100644 --- a/contrib/moses2/FF/Distortion.cpp +++ b/contrib/moses2/FF/Distortion.cpp @@ -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(value); - } - else { - StatefulFeatureFunction::SetParameter(key, value); - } -} - FFState* Distortion::BlankState(MemPool &pool, const System &sys) const { return new (pool.Allocate()) DistortionState_traditional(); @@ -121,7 +110,7 @@ void Distortion::EvaluateWhenApplied(const ManagerBase &mgr, const DistortionState_traditional &prev = static_cast(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, } } - diff --git a/contrib/moses2/FF/Distortion.h b/contrib/moses2/FF/Distortion.h index bc843fe54..45577d1c3 100644 --- a/contrib/moses2/FF/Distortion.h +++ b/contrib/moses2/FF/Distortion.h @@ -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; };