mosesdecoder/mert/CderScorer.h

55 lines
1.3 KiB
C
Raw Permalink Normal View History

#ifndef MERT_CDER_SCORER_H_
#define MERT_CDER_SCORER_H_
#include <string>
#include <vector>
#include "Types.h"
#include "StatisticsBasedScorer.h"
namespace MosesTuning
{
2013-05-29 21:16:15 +04:00
/**
* CderScorer class can compute both CDER and WER metric.
*/
2013-05-29 21:16:15 +04:00
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);
2013-05-29 21:16:15 +04:00
virtual std::size_t NumberOfScores() const {
return 2;
}
virtual float calculateScore(const std::vector<ScoreStatsType>& comps) const;
2017-07-22 02:01:14 +03:00
virtual float getReferenceLength(const std::vector<ScoreStatsType>& totals) const {
return totals[1];
2016-11-08 17:49:10 +03:00
}
2013-05-29 21:16:15 +04:00
private:
bool m_allowed_long_jumps;
typedef std::vector<int> sent_t;
std::vector<std::vector<sent_t> > m_ref_sentences;
2012-02-26 08:04:27 +04:00
void computeCD(const sent_t& cand, const sent_t& ref,
std::vector<ScoreStatsType>& stats) const;
2011-11-12 04:24:19 +04:00
// no copying allowed
CderScorer(const CderScorer&);
CderScorer& operator=(const CderScorer&);
};
}
#endif // MERT_CDER_SCORER_H_