diff options
author | Matous Machacek <machacekmatous@gmail.com> | 2012-02-28 05:27:23 +0400 |
---|---|---|
committer | Matous Machacek <machacekmatous@gmail.com> | 2012-02-28 05:27:23 +0400 |
commit | ba987c94ba9be5e7c8eb9c3e7c83d8f971fbd3aa (patch) | |
tree | 4140bd7b8fcef62012d2fe59956dcc81bb25c2bd /mert/evaluator.cpp | |
parent | e38cd12ef3385304a4b363ca9b9ab16ed886a2ff (diff) |
Support for using factors in mert and evaluator
example:
Use --factor "0|2" to use only first and third factor from nbest list and from reference.
If you use interpolated scorer, separate records with comma (e.g. --factor "0|2,1").
Diffstat (limited to 'mert/evaluator.cpp')
-rw-r--r-- | mert/evaluator.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/mert/evaluator.cpp b/mert/evaluator.cpp index 21556e9ee..3b2e0d61f 100644 --- a/mert/evaluator.cpp +++ b/mert/evaluator.cpp @@ -131,6 +131,7 @@ void usage() cerr << "[--sctype|-s] the scorer type (default BLEU)" << endl; cerr << "[--scconfig|-c] configuration string passed to scorer" << endl; cerr << "\tThis is of the form NAME1:VAL1,NAME2:VAL2 etc " << endl; + cerr << "[--factors|-f] list of factors passed to the scorer (e.g. 0|2)" << endl; cerr << "[--reference|-R] comma separated list of reference files" << endl; cerr << "[--candidate|-C] comma separated list of candidate files" << endl; cerr << "[--bootstrap|-b] number of booststraped samples (default 0 - no bootstraping)" << endl; @@ -164,6 +165,7 @@ static struct option long_options[] = { {"candidate", required_argument, 0, 'C'}, {"bootstrap", required_argument, 0, 'b'}, {"rseed", required_argument, 0, 'r'}, + {"factors", required_argument, 0, 'f'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; @@ -174,6 +176,7 @@ struct ProgramOption { vector<string> scorer_configs; string reference; string candidate; + vector<string> scorer_factors; int bootstrap; int seed; bool has_seed; @@ -190,11 +193,12 @@ void ParseCommandOptions(int argc, char** argv, ProgramOption* opt) { int c; int option_index; int last_scorer_index = -1; - while ((c = getopt_long(argc, argv, "s:c:R:C:b:r:h", long_options, &option_index)) != -1) { + while ((c = getopt_long(argc, argv, "s:c:R:C:b:r:f:h", long_options, &option_index)) != -1) { switch(c) { case 's': opt->scorer_types.push_back(string(optarg)); opt->scorer_configs.push_back(string("")); + opt->scorer_factors.push_back(string("")); last_scorer_index++; break; case 'c': @@ -213,6 +217,9 @@ void ParseCommandOptions(int argc, char** argv, ProgramOption* opt) { opt->seed = strtol(optarg, NULL, 10); opt->has_seed = true; break; + case 'f': + opt->scorer_factors[last_scorer_index] = string(optarg); + break; default: usage(); } @@ -223,6 +230,7 @@ void ParseCommandOptions(int argc, char** argv, ProgramOption* opt) { { opt->scorer_types.push_back(string("BLEU")); opt->scorer_configs.push_back(string("")); + opt->scorer_factors.push_back(string("")); } } @@ -268,6 +276,7 @@ int main(int argc, char** argv) for (size_t i = 0; i < option.scorer_types.size(); i++) { g_scorer = ScorerFactory::getScorer(option.scorer_types[i], option.scorer_configs[i]); + g_scorer->setFactors(option.scorer_factors[i]); g_scorer->setReferenceFiles(refFiles); EvaluatorUtil::evaluate(*fileIt, option.bootstrap); delete g_scorer; |