00001 #include "ScorerFactory.h"
00002
00003 #include <stdexcept>
00004 #include "Scorer.h"
00005 #include "BleuScorer.h"
00006 #include "BleuDocScorer.h"
00007 #include "PerScorer.h"
00008 #include "TerScorer.h"
00009 #include "CderScorer.h"
00010 #include "InterpolatedScorer.h"
00011 #include "SemposScorer.h"
00012 #include "PermutationScorer.h"
00013 #include "MeteorScorer.h"
00014 #include "M2Scorer.h"
00015 #include "HwcmScorer.h"
00016 #include "Reference.h"
00017
00018 using namespace std;
00019
00020 namespace MosesTuning
00021 {
00022
00023
00024 vector<string> ScorerFactory::getTypes()
00025 {
00026 vector<string> types;
00027 types.push_back(string("BLEU"));
00028 types.push_back(string("BLEUDOC"));
00029 types.push_back(string("PER"));
00030 types.push_back(string("TER"));
00031 types.push_back(string("CDER"));
00032 types.push_back(string("WER"));
00033 types.push_back(string("MERGE"));
00034 types.push_back(string("SEMPOS"));
00035 types.push_back(string("LRSCORE"));
00036 types.push_back(string("METEOR"));
00037 types.push_back(string("HWCM"));
00038 types.push_back(string("M2SCORER"));
00039 return types;
00040 }
00041
00042 Scorer* ScorerFactory::getScorer(const string& type, const string& config)
00043 {
00044 if (type == "BLEU") {
00045 return new BleuScorer(config);
00046 } else if (type == "BLEUDOC") {
00047 return new BleuDocScorer(config);
00048 } else if (type == "PER") {
00049 return new PerScorer(config);
00050 } else if (type == "TER") {
00051 return new TerScorer(config);
00052 } else if (type == "CDER") {
00053 return new CderScorer(config, true);
00054 } else if (type == "WER") {
00055
00056 return new CderScorer(config, false);
00057 } else if (type == "SEMPOS") {
00058 return new SemposScorer(config);
00059 } else if (type == "M2SCORER") {
00060 return new M2Scorer(config);
00061 } else if ((type == "HAMMING") || (type == "KENDALL")) {
00062 return (PermutationScorer*) new PermutationScorer(type, config);
00063 } else if (type == "METEOR") {
00064 return new MeteorScorer(config);
00065 } else if (type == "HWCM") {
00066 return new HwcmScorer(config);
00067 } else {
00068 if (type.find(',') != string::npos) {
00069 return new InterpolatedScorer(type, config);
00070 } else {
00071 throw runtime_error("Unknown scorer type: " + type);
00072 }
00073 }
00074 }
00075
00076 }
00077