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

BleuDocScorer.h « mert - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3497458257b1075858b83a3ce01cee15caff445a (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 MERT_BLEU_DOC_SCORER_H_
#define MERT_BLEU_DOC_SCORER_H_

#include <ostream>
#include <string>
#include <vector>

#include "Types.h"
#include "ScoreData.h"
#include "StatisticsBasedScorer.h"
#include "ScopedVector.h"
#include "BleuScorer.h"

namespace MosesTuning
{

/**
 * Bleu document scoring
 *
 * Needs xml reference files, and nbest lists where sentences are separated by '\n'
 */
class BleuDocScorer : public BleuScorer
{
public:

  explicit BleuDocScorer(const std::string& config = "");
  ~BleuDocScorer();

  virtual void prepareStats(std::size_t sid, const std::string& text, ScoreStats& entry);
  virtual statscore_t calculateScore(const std::vector<int>& comps) const;

  int CalcReferenceLength(std::size_t doc_id, std::size_t sentence_id, std::size_t length); 

  // NOTE: this function is used for unit testing.
  virtual bool OpenReferenceStream(std::istream* is, std::size_t file_id);

private:
  ReferenceLengthType m_ref_length_type;

  // reference translations.
  ScopedVector<ScopedVector<Reference> > m_references;

  // no copying allowed
  BleuDocScorer(const BleuDocScorer&);
  BleuDocScorer& operator=(const BleuDocScorer&);

  std::vector<std::string> splitDoc(const std::string& text);
};

/* /\** Computes sentence-level BLEU+1 score. */
/*  * This function is used in PRO. */
/*  *\/ */
/* float sentenceLevelBleuPlusOne(const std::vector<float>& stats); */

/* /\** Computes sentence-level BLEU score given a background corpus. */
/*  * This function is used in batch MIRA. */
/*  *\/ */
/* float sentenceLevelBackgroundBleu(const std::vector<float>& sent, const std::vector<float>& bg); */

/* /\** */
/*  * Computes plain old BLEU from a vector of stats */
/*  *\/ */
/* float unsmoothedBleu(const std::vector<float>& stats); */

}

#endif  // MERT_BLEU_DOC_SCORER_H_