blob: d86bb8ef9cee7fed4dac8379a237921810a35577 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#include "ScorerFactory.h"
#include <stdexcept>
#include "Scorer.h"
#include "BleuScorer.h"
#include "PerScorer.h"
#include "TerScorer.h"
#include "CderScorer.h"
#include "MergeScorer.h"
#include "InterpolatedScorer.h"
#include "SemposScorer.h"
#include "PermutationScorer.h"
using namespace std;
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"));
types.push_back(string("WER"));
types.push_back(string("MERGE"));
types.push_back(string("SEMPOS"));
types.push_back(string("LRSCORE"));
return types;
}
Scorer* ScorerFactory::getScorer(const string& type, const string& config) {
if (type == "BLEU") {
return new BleuScorer(config);
} else if (type == "PER") {
return new PerScorer(config);
} else if (type == "TER") {
return new TerScorer(config);
} else if (type == "CDER") {
return new CderScorer(config, true);
} else if (type == "WER") {
// CderScorer can compute both CDER and WER metric
return new CderScorer(config, false);
} else if (type == "SEMPOS") {
return new SemposScorer(config);
} else if (type == "MERGE") {
return new MergeScorer(config);
} else if (type == "LRSCORE") {
return new PermutationScorer(config);
} else {
if (type.find(',') != string::npos) {
return new InterpolatedScorer(type, config);
}
else {
throw runtime_error("Unknown scorer type: " + type);
}
}
}
|