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

StatisticsBasedScorer.h « mert - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5f4690edf318c0a3066e3c12e6d8e75092ec4799 (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
//
//  StatisticsBasedScorer.h
//  mert_lib
//
//  Created by Hieu Hoang on 23/06/2012.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#ifndef mert_lib_StatisticsBasedScorer_h
#define mert_lib_StatisticsBasedScorer_h

#include "Scorer.h"

#include "util/exception.hh"

namespace MosesTuning
{


/**
 * Abstract base class for Scorers that work by adding statistics across all
 * outout sentences, then apply some formula, e.g., BLEU, PER.
 */
class StatisticsBasedScorer : public Scorer
{
  friend class HopeFearDecoder;

public:
  StatisticsBasedScorer(const std::string& name, const std::string& config);
  virtual ~StatisticsBasedScorer() {}
  virtual void score(const candidates_t& candidates, const diffs_t& diffs,
                     statscores_t& scores) const;

protected:

  enum RegularisationType {
    NONE,
    AVERAGE,
    MINIMUM
  };

  /**
   * Calculate the actual score.
   */
  virtual statscore_t calculateScore(const std::vector<ScoreStatsType>& totals) const = 0;

  virtual float getReferenceLength(const std::vector<ScoreStatsType>& totals) const {}
//  {
//    UTIL_THROW(util::Exception, "getReferenceLength not implemented for this scorer type.");
//    return 0;
//  }

  // regularisation
  RegularisationType m_regularization_type;
  std::size_t  m_regularization_window;
};

} // namespace

#endif