2012-02-20 04:46:08 +04:00
|
|
|
#ifndef MERT_CDER_SCORER_H_
|
|
|
|
#define MERT_CDER_SCORER_H_
|
2011-08-19 01:35:16 +04:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include "Types.h"
|
2012-06-24 06:51:48 +04:00
|
|
|
#include "StatisticsBasedScorer.h"
|
2011-08-19 01:35:16 +04:00
|
|
|
|
2012-06-30 23:23:45 +04:00
|
|
|
namespace MosesTuning
|
|
|
|
{
|
2013-05-29 21:16:15 +04:00
|
|
|
|
2012-06-30 23:23:45 +04:00
|
|
|
|
2012-05-03 00:38:35 +04:00
|
|
|
/**
|
|
|
|
* CderScorer class can compute both CDER and WER metric.
|
|
|
|
*/
|
2013-05-29 21:16:15 +04:00
|
|
|
class CderScorer: public StatisticsBasedScorer
|
|
|
|
{
|
|
|
|
public:
|
2012-05-10 02:51:05 +04:00
|
|
|
explicit CderScorer(const std::string& config, bool allowed_long_jumps = true);
|
2011-11-12 05:16:31 +04:00
|
|
|
~CderScorer();
|
|
|
|
|
2012-05-10 02:51:05 +04:00
|
|
|
virtual void setReferenceFiles(const std::vector<std::string>& referenceFiles);
|
2012-02-01 16:44:37 +04:00
|
|
|
|
2012-05-10 02:51:05 +04:00
|
|
|
virtual void prepareStats(std::size_t sid, const std::string& text, ScoreStats& entry);
|
2012-02-01 16:44:37 +04:00
|
|
|
|
2014-09-16 19:36:45 +04:00
|
|
|
virtual void prepareStatsVector(std::size_t sid, const std::string& text, std::vector<ScoreStatsType>& stats);
|
2011-08-19 01:35:16 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
virtual std::size_t NumberOfScores() const {
|
|
|
|
return 2;
|
|
|
|
}
|
2011-08-19 01:35:16 +04:00
|
|
|
|
2014-09-16 19:36:45 +04:00
|
|
|
virtual float calculateScore(const std::vector<ScoreStatsType>& comps) const;
|
2011-08-19 01:35:16 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
private:
|
2012-05-03 00:38:35 +04:00
|
|
|
bool m_allowed_long_jumps;
|
2012-05-03 00:03:58 +04:00
|
|
|
|
2012-05-10 02:51:05 +04:00
|
|
|
typedef std::vector<int> sent_t;
|
|
|
|
std::vector<std::vector<sent_t> > m_ref_sentences;
|
2011-08-19 01:35:16 +04:00
|
|
|
|
2012-02-26 08:04:27 +04:00
|
|
|
void computeCD(const sent_t& cand, const sent_t& ref,
|
2014-09-16 19:36:45 +04:00
|
|
|
std::vector<ScoreStatsType>& stats) const;
|
2011-08-19 01:35:16 +04:00
|
|
|
|
2011-11-12 04:24:19 +04:00
|
|
|
// no copying allowed
|
2011-08-19 01:35:16 +04:00
|
|
|
CderScorer(const CderScorer&);
|
|
|
|
CderScorer& operator=(const CderScorer&);
|
|
|
|
};
|
|
|
|
|
2012-06-30 23:23:45 +04:00
|
|
|
}
|
|
|
|
|
2012-02-20 04:46:08 +04:00
|
|
|
#endif // MERT_CDER_SCORER_H_
|