00001 #pragma once 00002 00003 #include <string> 00004 #include "StatefulFeatureFunction.h" 00005 #include "moses/Range.h" 00006 00007 namespace Moses 00008 { 00009 00012 class DistortionScoreProducer : public StatefulFeatureFunction 00013 { 00014 protected: 00015 static std::vector<const DistortionScoreProducer*> s_staticColl; 00016 00017 FactorType m_sparseFactorTypeSource; 00018 FactorType m_sparseFactorTypeTarget; 00019 bool m_useSparse; 00020 bool m_sparseDistance; 00021 bool m_sparseSubordinate; 00022 FactorType m_sparseFactorTypeTargetSubordinate; 00023 const Factor* m_subordinateConjunctionTagFactor; 00024 00025 public: 00026 static const std::vector<const DistortionScoreProducer*>& GetDistortionFeatureFunctions() { 00027 return s_staticColl; 00028 } 00029 00030 DistortionScoreProducer(const std::string &line); 00031 00032 void SetParameter(const std::string& key, const std::string& value); 00033 00034 bool IsUseable(const FactorMask &mask) const { 00035 return true; 00036 } 00037 00038 static float CalculateDistortionScore(const Hypothesis& hypo, 00039 const Range &prev, const Range &curr, const int FirstGapPosition); 00040 00041 virtual const FFState* EmptyHypothesisState(const InputType &input) const; 00042 00043 virtual FFState* EvaluateWhenApplied( 00044 const Hypothesis& cur_hypo, 00045 const FFState* prev_state, 00046 ScoreComponentCollection* accumulator) const; 00047 00048 virtual FFState* EvaluateWhenApplied( 00049 const ChartHypothesis& /* cur_hypo */, 00050 int /* featureID - used to index the state in the previous hypotheses */, 00051 ScoreComponentCollection*) const { 00052 UTIL_THROW(util::Exception, "DIstortion not implemented in chart decoder"); 00053 } 00054 00055 }; 00056 } 00057