2011-11-14 15:06:10 +04:00
|
|
|
#include "ScorerFactory.h"
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
#include "Scorer.h"
|
|
|
|
#include "BleuScorer.h"
|
2013-07-03 16:03:58 +04:00
|
|
|
#include "BleuDocScorer.h"
|
2011-11-14 15:06:10 +04:00
|
|
|
#include "PerScorer.h"
|
|
|
|
#include "TerScorer.h"
|
|
|
|
#include "CderScorer.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
|
|
|
|
{
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
|
|
|
|
vector<string> ScorerFactory::getTypes()
|
|
|
|
{
|
2011-11-14 15:06:10 +04:00
|
|
|
vector<string> types;
|
|
|
|
types.push_back(string("BLEU"));
|
2013-07-03 16:03:58 +04:00
|
|
|
types.push_back(string("BLEUDOC"));
|
2011-11-14 15:06:10 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
Scorer* ScorerFactory::getScorer(const string& type, const string& config)
|
|
|
|
{
|
2011-11-14 15:06:10 +04:00
|
|
|
if (type == "BLEU") {
|
2012-03-23 17:39:24 +04:00
|
|
|
return new BleuScorer(config);
|
2013-07-03 16:03:58 +04:00
|
|
|
} else if (type == "BLEUDOC") {
|
|
|
|
return new BleuDocScorer(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);
|
2012-07-10 12:25:00 +04:00
|
|
|
} else if ((type == "HAMMING") || (type == "KENDALL")) {
|
|
|
|
return (PermutationScorer*) new PermutationScorer(type, 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);
|
2013-05-29 21:16:15 +04:00
|
|
|
} else {
|
2012-02-26 21:53:08 +04:00
|
|
|
throw runtime_error("Unknown scorer type: " + type);
|
|
|
|
}
|
2011-11-14 15:06:10 +04:00
|
|
|
}
|
|
|
|
}
|
2012-06-30 23:23:45 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|