Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Sennrich <rico.sennrich@gmx.ch>2014-09-17 17:14:11 +0400
committerRico Sennrich <rico.sennrich@gmx.ch>2014-09-22 13:49:20 +0400
commit3d00e5dc8ceb19d619e2ed2d0aa3f1b2a160944a (patch)
tree9d6a6fc32490d47aa0291c52285f53bf8d5abfac /mert/kbmira.cpp
parent6810b225ccd673c7684ab9b62e0daa0a7af054f3 (diff)
basic support for more metrics with kbmira
metrics need getReferenceLength (for background smoothing) to work with kbmira
Diffstat (limited to 'mert/kbmira.cpp')
-rw-r--r--mert/kbmira.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/mert/kbmira.cpp b/mert/kbmira.cpp
index 90f201a00..0be72e9f9 100644
--- a/mert/kbmira.cpp
+++ b/mert/kbmira.cpp
@@ -46,6 +46,9 @@ de recherches du Canada
#include "MiraFeatureVector.h"
#include "MiraWeightVector.h"
+#include "Scorer.h"
+#include "ScorerFactory.h"
+
using namespace std;
using namespace MosesTuning;
@@ -57,6 +60,8 @@ int main(int argc, char** argv)
string denseInitFile;
string sparseInitFile;
string type = "nbest";
+ string sctype = "BLEU";
+ string scconfig = "";
vector<string> scoreFiles;
vector<string> featureFiles;
vector<string> referenceFiles; //for hg mira
@@ -78,6 +83,8 @@ int main(int argc, char** argv)
desc.add_options()
("help,h", po::value(&help)->zero_tokens()->default_value(false), "Print this help message and exit")
("type,t", po::value<string>(&type), "Either nbest or hypergraph")
+ ("sctype", po::value<string>(&sctype), "the scorer type (default BLEU)")
+ ("scconfig,c", po::value<string>(&scconfig), "configuration string passed to scorer")
("scfile,S", po::value<vector<string> >(&scoreFiles), "Scorer data files")
("ffile,F", po::value<vector<string> > (&featureFiles), "Feature data files")
("hgdir,H", po::value<string> (&hgDir), "Directory containing hypergraphs")
@@ -209,19 +216,20 @@ int main(int argc, char** argv)
MiraWeightVector wv(initParams);
- // Initialize background corpus
- vector<ValType> bg;
- for(int j=0; j<kBleuNgramOrder; j++) {
- bg.push_back(kBleuNgramOrder-j);
- bg.push_back(kBleuNgramOrder-j);
+ // Initialize scorer
+ if(sctype != "BLEU" && type == "hypergraph") {
+ UTIL_THROW(util::Exception, "hypergraph mira only supports BLEU");
}
- bg.push_back(kBleuNgramOrder);
+ boost::scoped_ptr<Scorer> scorer(ScorerFactory::getScorer(sctype, scconfig));
+
+ // Initialize background corpus
+ vector<ValType> bg(scorer->NumberOfScores(), 1);
boost::scoped_ptr<HopeFearDecoder> decoder;
if (type == "nbest") {
- decoder.reset(new NbestHopeFearDecoder(featureFiles, scoreFiles, streaming, no_shuffle, safe_hope));
+ decoder.reset(new NbestHopeFearDecoder(featureFiles, scoreFiles, streaming, no_shuffle, safe_hope, scorer.get()));
} else if (type == "hypergraph") {
- decoder.reset(new HypergraphHopeFearDecoder(hgDir, referenceFiles, initDenseSize, streaming, no_shuffle, safe_hope, hgPruning, wv));
+ decoder.reset(new HypergraphHopeFearDecoder(hgDir, referenceFiles, initDenseSize, streaming, no_shuffle, safe_hope, hgPruning, wv, scorer.get()));
} else {
UTIL_THROW(util::Exception, "Unknown batch mira type: '" << type << "'");
}