File size: 1,571 Bytes
158b61b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once

#include <string>
#include "StatefulFeatureFunction.h"
#include "moses/Range.h"

namespace Moses
{

/** Calculates Distortion scores
 */
class DistortionScoreProducer : public StatefulFeatureFunction
{
protected:
  static std::vector<const DistortionScoreProducer*> s_staticColl;

  FactorType m_sparseFactorTypeSource;
  FactorType m_sparseFactorTypeTarget;
  bool m_useSparse;
  bool m_sparseDistance;
  bool m_sparseSubordinate;
  FactorType m_sparseFactorTypeTargetSubordinate;
  const Factor* m_subordinateConjunctionTagFactor;

public:
  static const std::vector<const DistortionScoreProducer*>& GetDistortionFeatureFunctions() {
    return s_staticColl;
  }

  DistortionScoreProducer(const std::string &line);

  void SetParameter(const std::string& key, const std::string& value);

  bool IsUseable(const FactorMask &mask) const {
    return true;
  }

  static float CalculateDistortionScore(const Hypothesis& hypo,
                                        const Range &prev, const Range &curr, const int FirstGapPosition);

  virtual const FFState* EmptyHypothesisState(const InputType &input) const;

  virtual FFState* EvaluateWhenApplied(
    const Hypothesis& cur_hypo,
    const FFState* prev_state,
    ScoreComponentCollection* accumulator) const;

  virtual FFState* EvaluateWhenApplied(
    const ChartHypothesis& /* cur_hypo */,
    int /* featureID - used to index the state in the previous hypotheses */,
    ScoreComponentCollection*) const {
    UTIL_THROW(util::Exception, "DIstortion not implemented in chart decoder");
  }

};
}