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

PhraseBoundaryFeature.h « src « moses - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4167ab9b2a6f9b060e1de88dfd9bea5b13bfd034 (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
60
61
62
63
64
65
66
67
#ifndef moses_PhraseBoundaryFeature_h
#define moses_PhraseBoundaryFeature_h

#include <sstream>
#include <string>

#include "FeatureFunction.h"
#include "FFState.h"
#include "Word.h"

namespace Moses
{

class PhraseBoundaryState : public FFState {
public:
  PhraseBoundaryState(const Word* sourceWord, const Word* targetWord) :
     m_sourceWord(sourceWord), m_targetWord(targetWord) {}
  const Word* GetSourceWord() const {return m_sourceWord;}
  const Word* GetTargetWord() const {return m_targetWord;}
  virtual int Compare(const FFState& other) const;


private:
  const Word* m_sourceWord;
  const Word* m_targetWord;
};


/**
 * Concatenations of factors on boundaries of phrases.
 **/
class PhraseBoundaryFeature : public StatefulFeatureFunction {
public:
  PhraseBoundaryFeature(const FactorList& sourceFactors, const FactorList& targetFactors);

  size_t GetNumScoreComponents() const;
  std::string GetScoreProducerWeightShortName(unsigned) const;
  size_t GetNumInputScores() const;

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

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

  virtual FFState* EvaluateChart( const ChartHypothesis& /* cur_hypo */,
                                  int /* featureID */,
                                  ScoreComponentCollection* ) const
                                  {
                                    abort();
                                  }
  
  void SetSparseProducerWeight(float weight) { m_sparseProducerWeight = weight; }
  float GetSparseProducerWeight() const { return m_sparseProducerWeight; }
  
private:
  void AddFeatures(
    const Word* leftWord, const Word* rightWord, const FactorList& factors, 
    const std::string& side, ScoreComponentCollection* scores) const ;
  FactorList m_sourceFactors;
  FactorList m_targetFactors;
  float m_sparseProducerWeight;
};

}


#endif