Include chrf as a metric

This commit is contained in:
Prashant Mathur 2018-05-18 16:18:19 +02:00
parent 8b59644945
commit fb478bf1db
3 changed files with 15 additions and 5 deletions

View File

@ -47,11 +47,16 @@ public:
virtual float calculateScore(const std::vector<ScoreStatsType>& totals) const = 0;
float calculateSentenceLevelBackgroundScore(const std::vector<ScoreStatsType>& totals, const std::vector<ScoreStatsType>& bg) {
std::vector<ScoreStatsType> stats(totals.size());
for(size_t i=0; i<stats.size(); i++)
stats[i] = totals[i]+bg[i];
// Get score and scale by reference length (as per Chiang et al 08)
return calculateScore(stats) * getReferenceLength(stats);
if (m_name.compare("CHRF")!=0){
std::vector<ScoreStatsType> stats(totals.size());
for(size_t i=0; i<stats.size(); i++)
stats[i] = totals[i]+bg[i];
// Get score and scale by reference length (as per Chiang et al 08)
return calculateScore(stats) * getReferenceLength(stats);
}
else{
return calculateScore(totals);
}
}
/**

View File

@ -6,6 +6,7 @@
#include "BleuDocScorer.h"
#include "PerScorer.h"
#include "TerScorer.h"
#include "CHRFScorer.h"
#include "CderScorer.h"
#include "InterpolatedScorer.h"
#include "SemposScorer.h"
@ -29,6 +30,7 @@ vector<string> ScorerFactory::getTypes()
types.push_back(string("PER"));
types.push_back(string("TER"));
types.push_back(string("CDER"));
types.push_back(string("CHRF"));
types.push_back(string("WER"));
types.push_back(string("MERGE"));
types.push_back(string("SEMPOS"));
@ -62,6 +64,8 @@ Scorer* ScorerFactory::getScorer(const string& type, const string& config)
return (PermutationScorer*) new PermutationScorer(type, config);
} else if (type == "METEOR") {
return new MeteorScorer(config);
} else if (type == "CHRF") {
return new CHRFScorer(config);
} else if (type == "HWCM") {
return new HwcmScorer(config);
} else {

View File

@ -43,6 +43,7 @@ de recherches du Canada
#include "util/random.hh"
#include "BleuScorer.h"
#include "CHRFScorer.h"
#include "HopeFearDecoder.h"
#include "MiraFeatureVector.h"
#include "MiraWeightVector.h"