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

TargetConstituentAdjacencyFeature.h « FF « moses - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f5305e0df0679d543b37ec7d7bf52a3a0c216057 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#pragma once

#include <string>
#include <vector>
#include <set>
#include <iostream>
#include "StatefulFeatureFunction.h"
#include "FFState.h"
#include "util/exception.hh"
#include <stdint.h>

namespace Moses
{

class TargetConstituentAdjacencyFeatureState : public FFState
{

public:

  friend class TargetConstituentAdjacencyFeature;

  TargetConstituentAdjacencyFeatureState(bool recombine)
    : m_recombine(recombine)
  {};

  size_t hash() const;

  virtual bool operator==(const FFState& other) const;

private:

  const bool m_recombine;
  std::map<const Factor*, float> m_collection;

};


class TargetConstituentAdjacencyFeature : public StatefulFeatureFunction
{

public:

  TargetConstituentAdjacencyFeature(const std::string &line);

  ~TargetConstituentAdjacencyFeature()
  {};

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

  virtual const FFState* EmptyHypothesisState(const InputType &input) const {
    return new TargetConstituentAdjacencyFeatureState(m_recombine);
  };

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

  void Load(AllOptions::ptr const& opts)
  {};

  void EvaluateInIsolation(const Phrase &source
                           , const TargetPhrase &targetPhrase
                           , ScoreComponentCollection &scoreBreakdown
                           , ScoreComponentCollection &estimatedFutureScore) const
  {};

  void EvaluateWithSourceContext(const InputType &input
                                 , const InputPath &inputPath
                                 , const TargetPhrase &targetPhrase
                                 , const StackVec *stackVec
                                 , ScoreComponentCollection &scoreBreakdown
                                 , ScoreComponentCollection *estimatedFutureScore = NULL) const
  {};

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

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

  FFState* EvaluateWhenApplied(
    const ChartHypothesis& cur_hypo,
    int featureID, // used to index the state in the previous hypotheses
    ScoreComponentCollection* accumulator) const {
    UTIL_THROW2(GetScoreProducerDescription() << ": feature currently not implemented for chart-based decoding.");
    return new TargetConstituentAdjacencyFeatureState(m_recombine);
  };


private:

  size_t m_featureVariant;
  bool m_recombine;

};

}