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

scorer-impl.h « memscore « contrib - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bc544f12e86704efcf9c8e07e0c2103dae0f0b38 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// memscore - in-memory phrase scoring for Statistical Machine Translation
// Christian Hardmeier, FBK-irst, Trento, 2010
// $Id$

#ifndef SCORER_IMPL_H
#define SCORER_IMPL_H

#include "phrasetable.h"
#include "scorer.h"

class MLPhraseScorer : public PhraseScorer
{
private:
  explicit MLPhraseScorer(PhraseTable &pd, bool reverse) :
    PhraseScorer(pd, reverse) {}

  virtual void do_score_phrases();
  virtual Score do_get_score(const PhraseTable::const_iterator &it);

public:
  static PhraseScorer *create_scorer(const char *argv[], int &argp, bool reverse, const PhraseScorerFactory &ptf);
};

class WittenBellPhraseScorer : public PhraseScorer
{
private:
  explicit WittenBellPhraseScorer(PhraseTable &pd, bool reverse) :
    PhraseScorer(pd, reverse) {}

  virtual Score do_get_score(const PhraseTable::const_iterator &it);

public:
  static PhraseScorer *create_scorer(const char *argv[], int &argp, bool reverse, const PhraseScorerFactory &ptf);
};

class AbsoluteDiscountPhraseScorer : public PhraseScorer
{
private:
  Score discount_;

  explicit AbsoluteDiscountPhraseScorer(PhraseTable &pd, bool reverse) :
    PhraseScorer(pd, reverse) {}

  virtual void do_score_phrases();
  virtual Score do_get_score(const PhraseTable::const_iterator &it);

public:
  Score get_discount();
  static PhraseScorer *create_scorer(const char *argv[], int &argp, bool reverse, const PhraseScorerFactory &ptf);
};

class KNDiscount1PhraseScorer : public PhraseScorer
{
private:
  Count total_distinct_;
  Score discount_;
  Count total_count_;

  explicit KNDiscount1PhraseScorer(PhraseTable &pd, bool reverse) :
    PhraseScorer(pd, reverse) {}

  virtual void do_score_phrases();
  virtual Score do_get_score(const PhraseTable::const_iterator &it);

public:
  static PhraseScorer *create_scorer(const char *argv[], int &argp, bool reverse, const PhraseScorerFactory &ptf);
};

class KNDiscount3PhraseScorer : public PhraseScorer
{
private:
  Score discount1_;
  Score discount2_;
  Score discount3plus_;

  Count total_distinct_n1_;
  Count total_distinct_n2_;
  Count total_distinct_n3plus_;

  explicit KNDiscount3PhraseScorer(PhraseTable &pd, bool reverse) :
    PhraseScorer(pd, reverse) {}

  virtual void do_score_phrases();
  virtual Score do_get_score(const PhraseTable::const_iterator &it);

public:
  static PhraseScorer *create_scorer(const char *argv[], int &argp, bool reverse, const PhraseScorerFactory &ptf);
};

class LexicalWeightPhraseScorer : public PhraseScorer
{
private:
  typedef std::map<std::pair<Count,Count>,Score> WeightMapType_;

  WeightMapType_ weight_map_;
  bool overall_max_score_;
  const Count null_word_;

  LexicalWeightPhraseScorer(PhraseTable &pd, bool reverse, const String &weights, bool overall_max = true);

  Score get_weight(const String &s_src, const String &s_tgt) const;
  Score get_weight(Count src, Count tgt) const;

  virtual void do_score_phrases();
  virtual Score do_get_score(const PhraseTable::const_iterator &it);

public:
  static PhraseScorer *create_scorer(const char *argv[], int &argp, bool reverse, const PhraseScorerFactory &ptf);
};

class ConstantPhraseScorer : public PhraseScorer
{
private:
  Score constant_;

  ConstantPhraseScorer(PhraseTable &pt, bool reverse, Score constant) : PhraseScorer(pt, reverse), constant_(constant) {}

  virtual Score do_get_score(const PhraseTable::const_iterator &it);

public:
  static PhraseScorer *create_scorer(const char *argv[], int &argp, bool reverse, const PhraseScorerFactory &ptf);
};

#endif