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

TargetBigramFeature.h « FF « moses - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f6e9658085bb6ca064a671a440b2bf2245d917b0 (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
68
69
70
71
72
73
74
75
76
77
78
#ifndef moses_TargetBigramFeature_h
#define moses_TargetBigramFeature_h

#include <string>
#include <map>
#include <boost/unordered_set.hpp>

#include "moses/FF/FFState.h"
#include "StatefulFeatureFunction.h"
#include "moses/FactorCollection.h"
#include "moses/Word.h"

namespace Moses
{

class TargetBigramState : public FFState
{
public:
  TargetBigramState(const Word& word): m_word(word) {}
  const Word& GetWord() const {
    return m_word;
  }
  virtual int Compare(const FFState& other) const;

private:
  Word m_word;
};

/** Sets the features of observed bigrams.
 */
class TargetBigramFeature : public StatefulFeatureFunction
{
public:
  TargetBigramFeature(const std::string &line);

  void Load();

  bool IsUseable(const FactorMask &mask) const;

  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 */,
                                        ScoreComponentCollection* ) const {
    throw std::logic_error("TargetBigramFeature not valid in chart decoder");
  }
  void EvaluateWithSourceContext(const InputType &input
                                 , const InputPath &inputPath
                                 , const TargetPhrase &targetPhrase
                                 , const StackVec *stackVec
                                 , ScoreComponentCollection &scoreBreakdown
                                 , ScoreComponentCollection *estimatedFutureScore = NULL) const {
  }
  void EvaluateInIsolation(const Phrase &source
                           , const TargetPhrase &targetPhrase
                           , ScoreComponentCollection &scoreBreakdown
                           , ScoreComponentCollection &estimatedFutureScore) const {
  }

  void EvaluateTranslationOptionListWithSourceContext(const InputType &input
      , const TranslationOptionList &translationOptionList) const {
  }

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

private:
  FactorType m_factorType;
  Word m_bos;
  std::string m_filePath;
  boost::unordered_set<std::string> m_vocab;
};

}

#endif // moses_TargetBigramFeature_h