2012-02-20 04:46:08 +04:00
|
|
|
#ifndef MERT_PER_SCORER_H_
|
|
|
|
#define MERT_PER_SCORER_H_
|
2008-05-27 20:50:52 +04:00
|
|
|
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include "Types.h"
|
2012-06-24 06:51:48 +04:00
|
|
|
#include "StatisticsBasedScorer.h"
|
2008-05-27 20:50:52 +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
|
|
|
|
2011-11-14 10:15:30 +04:00
|
|
|
class ScoreStats;
|
|
|
|
|
2008-05-27 20:50:52 +04:00
|
|
|
/**
|
2011-11-12 03:58:23 +04:00
|
|
|
* An implementation of position-independent word error rate.
|
|
|
|
* This is defined as
|
|
|
|
* 1 - (correct - max(0,output_length - ref_length)) / ref_length
|
|
|
|
* In fact, we ignore the " 1 - " so that it can be maximised.
|
|
|
|
*/
|
2011-02-24 15:42:19 +03:00
|
|
|
class PerScorer: public StatisticsBasedScorer
|
|
|
|
{
|
|
|
|
public:
|
2012-05-10 02:51:05 +04:00
|
|
|
explicit PerScorer(const std::string& config = "");
|
2011-11-12 05:16:31 +04:00
|
|
|
~PerScorer();
|
|
|
|
|
2012-05-10 02:51:05 +04:00
|
|
|
virtual void setReferenceFiles(const std::vector<std::string>& referenceFiles);
|
|
|
|
virtual void prepareStats(std::size_t sid, const std::string& text, ScoreStats& entry);
|
2013-05-29 21:16:15 +04:00
|
|
|
virtual std::size_t NumberOfScores() const {
|
|
|
|
return 3;
|
|
|
|
}
|
2014-09-16 19:36:45 +04:00
|
|
|
virtual float calculateScore(const std::vector<ScoreStatsType>& comps) const;
|
2011-02-24 15:42:19 +03:00
|
|
|
|
|
|
|
private:
|
2011-11-12 03:58:23 +04:00
|
|
|
// no copying allowed
|
2011-02-24 15:42:19 +03:00
|
|
|
PerScorer(const PerScorer&);
|
|
|
|
PerScorer& operator=(const PerScorer&);
|
|
|
|
|
|
|
|
// data extracted from reference files
|
2012-05-10 02:51:05 +04:00
|
|
|
std::vector<std::size_t> m_ref_lengths;
|
|
|
|
std::vector<std::multiset<int> > m_ref_tokens;
|
2008-05-27 20:50:52 +04:00
|
|
|
};
|
|
|
|
|
2012-06-30 23:23:45 +04:00
|
|
|
}
|
|
|
|
|
2012-02-20 04:46:08 +04:00
|
|
|
#endif // MERT_PER_SCORER_H_
|