File size: 1,329 Bytes
158b61b |
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 |
#ifndef MERT_CDER_SCORER_H_
#define MERT_CDER_SCORER_H_
#include <string>
#include <vector>
#include "Types.h"
#include "StatisticsBasedScorer.h"
namespace MosesTuning
{
/**
* CderScorer class can compute both CDER and WER metric.
*/
class CderScorer: public StatisticsBasedScorer
{
public:
explicit CderScorer(const std::string& config, bool allowed_long_jumps = true);
~CderScorer();
virtual void setReferenceFiles(const std::vector<std::string>& referenceFiles);
virtual void prepareStats(std::size_t sid, const std::string& text, ScoreStats& entry);
virtual void prepareStatsVector(std::size_t sid, const std::string& text, std::vector<ScoreStatsType>& stats);
virtual std::size_t NumberOfScores() const {
return 2;
}
virtual float calculateScore(const std::vector<ScoreStatsType>& comps) const;
virtual float getReferenceLength(const std::vector<ScoreStatsType>& totals) const {
return totals[1];
}
private:
bool m_allowed_long_jumps;
typedef std::vector<int> sent_t;
std::vector<std::vector<sent_t> > m_ref_sentences;
void computeCD(const sent_t& cand, const sent_t& ref,
std::vector<ScoreStatsType>& stats) const;
// no copying allowed
CderScorer(const CderScorer&);
CderScorer& operator=(const CderScorer&);
};
}
#endif // MERT_CDER_SCORER_H_
|