2011-11-14 15:06:10 +04:00
|
|
|
#include "ScorerFactory.h"
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
#include "Scorer.h"
|
|
|
|
#include "BleuScorer.h"
|
|
|
|
#include "PerScorer.h"
|
|
|
|
#include "TerScorer.h"
|
|
|
|
#include "CderScorer.h"
|
|
|
|
#include "MergeScorer.h"
|
2012-02-26 21:53:08 +04:00
|
|
|
#include "InterpolatedScorer.h"
|
2012-03-23 17:39:24 +04:00
|
|
|
#include "SemposScorer.h"
|
2012-06-22 21:19:16 +04:00
|
|
|
#include "PermutationScorer.h"
|
2011-11-14 15:06:10 +04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2012-06-30 23:23:45 +04:00
|
|
|
namespace MosesTuning
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2011-11-14 15:06:10 +04:00
|
|
|
vector<string> ScorerFactory::getTypes() {
|
|
|
|
vector<string> types;
|
|
|
|
types.push_back(string("BLEU"));
|
|
|
|
types.push_back(string("PER"));
|
|
|
|
types.push_back(string("TER"));
|
|
|
|
types.push_back(string("CDER"));
|
2012-05-03 00:03:58 +04:00
|
|
|
types.push_back(string("WER"));
|
2011-11-14 15:06:10 +04:00
|
|
|
types.push_back(string("MERGE"));
|
2012-03-23 17:39:24 +04:00
|
|
|
types.push_back(string("SEMPOS"));
|
2012-06-22 21:19:16 +04:00
|
|
|
types.push_back(string("LRSCORE"));
|
2011-11-14 15:06:10 +04:00
|
|
|
return types;
|
|
|
|
}
|
|
|
|
|
|
|
|
Scorer* ScorerFactory::getScorer(const string& type, const string& config) {
|
|
|
|
if (type == "BLEU") {
|
2012-03-23 17:39:24 +04:00
|
|
|
return new BleuScorer(config);
|
2011-11-14 15:06:10 +04:00
|
|
|
} else if (type == "PER") {
|
2012-03-23 17:39:24 +04:00
|
|
|
return new PerScorer(config);
|
2011-11-14 15:06:10 +04:00
|
|
|
} else if (type == "TER") {
|
2012-03-23 17:39:24 +04:00
|
|
|
return new TerScorer(config);
|
2011-11-14 15:06:10 +04:00
|
|
|
} else if (type == "CDER") {
|
2012-05-03 00:03:58 +04:00
|
|
|
return new CderScorer(config, true);
|
|
|
|
} else if (type == "WER") {
|
|
|
|
// CderScorer can compute both CDER and WER metric
|
|
|
|
return new CderScorer(config, false);
|
2012-03-23 17:39:24 +04:00
|
|
|
} else if (type == "SEMPOS") {
|
|
|
|
return new SemposScorer(config);
|
2011-11-14 15:06:10 +04:00
|
|
|
} else if (type == "MERGE") {
|
2012-03-23 17:39:24 +04:00
|
|
|
return new MergeScorer(config);
|
2012-06-23 06:23:14 +04:00
|
|
|
} else if (type == "LRSCORE") {
|
2012-06-22 21:19:16 +04:00
|
|
|
return new PermutationScorer(config);
|
2011-11-14 15:06:10 +04:00
|
|
|
} else {
|
2012-02-26 21:53:08 +04:00
|
|
|
if (type.find(',') != string::npos) {
|
|
|
|
return new InterpolatedScorer(type, config);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
throw runtime_error("Unknown scorer type: " + type);
|
|
|
|
}
|
2011-11-14 15:06:10 +04:00
|
|
|
}
|
|
|
|
}
|
2012-06-30 23:23:45 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|