Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Distortion.h « FF « moses2 - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 685aa1445b387e49085a622d316ad7fb7be3985f (plain)
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
59
/*
 * Distortion.h
 *
 *  Created on: 28 Oct 2015
 *      Author: hieu
 */

#ifndef DISTORTION_H_
#define DISTORTION_H_

#include "StatefulFeatureFunction.h"
#include "../legacy/Range.h"
#include "../TypeDef.h"

namespace Moses2
{

class Distortion: public StatefulFeatureFunction
{
public:
  Distortion(size_t startInd, const std::string &line);
  virtual ~Distortion();

  virtual FFState* BlankState(MemPool &pool, const System &sys) const;
  virtual void EmptyHypothesisState(FFState &state, const ManagerBase &mgr,
                                    const InputType &input, const Hypothesis &hypo) const;

  virtual void
  EvaluateInIsolation(MemPool &pool, const System &system, const Phrase<Moses2::Word> &source,
                      const TargetPhraseImpl &targetPhrase, Scores &scores,
                      SCORE &estimatedScore) const;

  virtual void
  EvaluateInIsolation(MemPool &pool, const System &system, const Phrase<SCFG::Word> &source,
                      const TargetPhrase<SCFG::Word> &targetPhrase, Scores &scores,
                      SCORE &estimatedScore) const;

  virtual void EvaluateWhenApplied(const std::deque<Hypothesis*> &hypos) const {
  }

  virtual void EvaluateWhenApplied(const ManagerBase &mgr,
                                   const Hypothesis &hypo, const FFState &prevState, Scores &scores,
                                   FFState &state) const;

  virtual void EvaluateWhenApplied(const SCFG::Manager &mgr,
                                   const SCFG::Hypothesis &hypo, int featureID, Scores &scores,
                                   FFState &state) const;

protected:
  SCORE CalculateDistortionScore(const Range &prev, const Range &curr,
                                 const int FirstGap) const;

  int ComputeDistortionDistance(const Range& prev, const Range& current) const;

};

}

#endif /* DISTORTION_H_ */