2008-06-03 12:56:37 +04:00
|
|
|
#ifndef __SCORER_FACTORY_H
|
|
|
|
#define __SCORER_FACTORY_H
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <cmath>
|
|
|
|
#include <iostream>
|
|
|
|
#include <iterator>
|
|
|
|
#include <set>
|
|
|
|
#include <sstream>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include "Types.h"
|
|
|
|
#include "Scorer.h"
|
|
|
|
#include "BleuScorer.h"
|
|
|
|
#include "PerScorer.h"
|
2011-08-16 20:21:31 +04:00
|
|
|
#include "TerScorer.h"
|
2011-08-19 01:35:16 +04:00
|
|
|
#include "CderScorer.h"
|
2011-10-05 17:36:17 +04:00
|
|
|
#include "MergeScorer.h"
|
2008-06-03 12:56:37 +04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2011-02-24 15:42:19 +03:00
|
|
|
class ScorerFactory
|
|
|
|
{
|
|
|
|
public:
|
2011-11-11 15:40:59 +04:00
|
|
|
static vector<string> getTypes() {
|
2011-02-24 15:42:19 +03:00
|
|
|
vector<string> types;
|
|
|
|
types.push_back(string("BLEU"));
|
|
|
|
types.push_back(string("PER"));
|
2011-08-16 20:21:31 +04:00
|
|
|
types.push_back(string("TER"));
|
2011-08-19 01:35:16 +04:00
|
|
|
types.push_back(string("CDER"));
|
2011-10-05 17:36:17 +04:00
|
|
|
types.push_back(string("MERGE"));
|
2011-02-24 15:42:19 +03:00
|
|
|
return types;
|
|
|
|
}
|
2008-06-03 12:56:37 +04:00
|
|
|
|
2011-11-11 15:40:59 +04:00
|
|
|
static Scorer* getScorer(const string& type, const string& config = "") {
|
2011-02-24 15:42:19 +03:00
|
|
|
if (type == "BLEU") {
|
|
|
|
return (BleuScorer*) new BleuScorer(config);
|
|
|
|
} else if (type == "PER") {
|
|
|
|
return (PerScorer*) new PerScorer(config);
|
2011-09-06 02:26:18 +04:00
|
|
|
} else if (type == "TER") {
|
2011-08-16 20:21:31 +04:00
|
|
|
return (TerScorer*) new TerScorer(config);
|
2011-09-06 02:26:18 +04:00
|
|
|
} else if (type == "CDER") {
|
2011-08-19 01:35:16 +04:00
|
|
|
return (CderScorer*) new CderScorer(config);
|
2011-10-05 17:36:17 +04:00
|
|
|
} else if (type == "MERGE") {
|
|
|
|
return (MergeScorer*) new MergeScorer(config);
|
2011-02-24 15:42:19 +03:00
|
|
|
} else {
|
|
|
|
throw runtime_error("Unknown scorer type: " + type);
|
|
|
|
}
|
|
|
|
}
|
2011-11-11 15:40:59 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
ScorerFactory() {}
|
|
|
|
~ScorerFactory() {}
|
2008-06-03 12:56:37 +04:00
|
|
|
};
|
|
|
|
|
2011-11-12 02:59:50 +04:00
|
|
|
#endif // __SCORER_FACTORY_H
|