From 2835ea63e0b7282077308940df66179d26a2f2aa Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Tue, 19 Feb 2013 18:31:59 +0000 Subject: [PATCH] getting rid of m_distortionScoreProducer in staticdata --- moses/BitmapContainer.cpp | 9 +++++---- moses/DummyScoreProducers.cpp | 2 +- moses/DummyScoreProducers.h | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/moses/BitmapContainer.cpp b/moses/BitmapContainer.cpp index 4dd63141f..c21cd552a 100644 --- a/moses/BitmapContainer.cpp +++ b/moses/BitmapContainer.cpp @@ -61,15 +61,16 @@ public: bool operator()(const Hypothesis* hypoA, const Hypothesis* hypoB) const { CHECK(m_transOptRange != NULL); - const float weightDistortion = StaticData::Instance().GetWeightDistortion(); - const DistortionScoreProducer *dsp = StaticData::Instance().GetDistortionProducer(); - const float distortionScoreA = dsp->CalculateDistortionScore( + const StaticData &staticData = StaticData::Instance(); + const float weightDistortion = staticData.GetWeightDistortion(); + + const float distortionScoreA = DistortionScoreProducer::CalculateDistortionScore( *hypoA, hypoA->GetCurrSourceWordsRange(), *m_transOptRange, hypoA->GetWordsBitmap().GetFirstGapPos() ); - const float distortionScoreB = dsp->CalculateDistortionScore( + const float distortionScoreB = DistortionScoreProducer::CalculateDistortionScore( *hypoB, hypoB->GetCurrSourceWordsRange(), *m_transOptRange, diff --git a/moses/DummyScoreProducers.cpp b/moses/DummyScoreProducers.cpp index 601b4f770..27a1ad715 100644 --- a/moses/DummyScoreProducers.cpp +++ b/moses/DummyScoreProducers.cpp @@ -39,7 +39,7 @@ const FFState* DistortionScoreProducer::EmptyHypothesisState(const InputType &in } float DistortionScoreProducer::CalculateDistortionScore(const Hypothesis& hypo, - const WordsRange &prev, const WordsRange &curr, const int FirstGap) const + const WordsRange &prev, const WordsRange &curr, const int FirstGap) { if(!StaticData::Instance().UseEarlyDistortionCost()) { return - (float) hypo.GetInput().ComputeDistortionDistance(prev, curr); diff --git a/moses/DummyScoreProducers.h b/moses/DummyScoreProducers.h index 00eb603c3..80dc7adc4 100644 --- a/moses/DummyScoreProducers.h +++ b/moses/DummyScoreProducers.h @@ -19,8 +19,8 @@ public: : StatefulFeatureFunction("Distortion", 1, line) {} - float CalculateDistortionScore(const Hypothesis& hypo, - const WordsRange &prev, const WordsRange &curr, const int FirstGapPosition) const; + static float CalculateDistortionScore(const Hypothesis& hypo, + const WordsRange &prev, const WordsRange &curr, const int FirstGapPosition); virtual const FFState* EmptyHypothesisState(const InputType &input) const;