Cambridge SMT System
BleuStats.h
Go to the documentation of this file.
1 //Copyright (c) 2012, University of Cambridge
2 //All rights reserved.
3 //
4 //Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met://
5 //
6 // * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 // * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8 // * Neither the name of the University of Cambridge nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9 //
10 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 
12 #ifndef BLEUSTATS_H_
13 #define BLEUSTATS_H_
14 
15 #include <iostream>
16 #include <vector>
17 #include <limits>
18 
19 using std::ostream;
20 using std::vector;
21 
22 class Bleu {
23  public:
24  Bleu (const double bleu = -std::numeric_limits<double>::infinity(),
25  const double brev = 0) :
26  m_bleu (bleu), m_brev (brev) {
27  }
28  inline double GetError() const {
29  return m_bleu;
30  }
31 
32  friend ostream& operator<< (ostream&, const Bleu&);
33 
34  friend bool operator> (Bleu&, Bleu&);
35 
36  private:
37  double m_bleu;
38  double m_brev;
39 };
40 
41 class BleuStats {
42  public:
43  typedef Bleu Error;
44  BleuStats();
45  vector<int> tots; // order-specific ngram totals
46  vector<int> hits; // order-specific ngram hits
47  long refLength; // effective reference length
48  Error ComputeError (const unsigned int = 4) const;
49 
50  static const unsigned int MAX_BLEU_ORDER;
51 };
52 
53 ostream& operator<< (ostream& o, const BleuStats& b);
54 
55 BleuStats operator+ (const BleuStats&, const BleuStats&);
56 
57 BleuStats operator- (const BleuStats&, const BleuStats&);
58 
59 #endif /* BLEUSTATS_H_ */
RefData::ErrorStats::Error ComputeError(RefData &refData, const TuneSet &lats, const PARAMS &lambda)
Definition: Score.h:22
friend bool operator>(Bleu &, Bleu &)
Definition: BleuStats.cpp:72
BleuStats operator+(const BleuStats &, const BleuStats &)
Definition: BleuStats.cpp:47
friend ostream & operator<<(ostream &, const Bleu &)
Definition: BleuStats.cpp:67
vector< int > hits
Definition: BleuStats.h:46
vector< int > tots
Definition: BleuStats.h:45
long refLength
Definition: BleuStats.h:47
Bleu Error
Definition: BleuStats.h:43
static const unsigned int MAX_BLEU_ORDER
Definition: BleuStats.h:50
Definition: BleuStats.h:22
BleuStats operator-(const BleuStats &, const BleuStats &)
Definition: BleuStats.cpp:57
double GetError() const
Definition: BleuStats.h:28
Bleu(const double bleu=-std::numeric_limits< double >::infinity(), const double brev=0)
Definition: BleuStats.h:24