diff options
author | Tetsuo Kiso <tetsuo-s@is.naist.jp> | 2012-01-26 22:39:13 +0400 |
---|---|---|
committer | Tetsuo Kiso <tetsuo-s@is.naist.jp> | 2012-01-26 22:39:13 +0400 |
commit | 940dadaa4c574c8461ed013b9e4defc93e235c06 (patch) | |
tree | 89e59e3f95eb6e45b600abb773ce087845cd186e /mert/evaluator.cpp | |
parent | f9eac588e7bb4a39c0141851198fe8c599804aaf (diff) |
Add whitespaces.
Diffstat (limited to 'mert/evaluator.cpp')
-rw-r--r-- | mert/evaluator.cpp | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/mert/evaluator.cpp b/mert/evaluator.cpp index 7119aa1ad..4c85c8a6a 100644 --- a/mert/evaluator.cpp +++ b/mert/evaluator.cpp @@ -7,11 +7,10 @@ #include <math.h> #include "Scorer.h" +#include "ScorerFactory.h" #include "Timer.h" #include "Util.h" -#include "ScorerFactory.h" - using namespace std; void evaluate(const string& candFile); @@ -29,35 +28,35 @@ const float g_alpha = 0.05; void usage() { - cerr<<"usage: evaluator [options] --reference ref1[,ref2[,ref3...]] --candidate cand1[,cand2[,cand3...]] "<<endl; - 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<<"[--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; - cerr<<"[--rseed|-r] the random seed for bootstraping (defaults to system clock)"<<endl; - cerr<<"[--help|-h] print this message and exit"<<endl; - cerr<<endl; - cerr<<"Evaluator is able to compute more metrics at once. To do this,"<<endl; - cerr<<"separate scorers with semicolon (note that comma is used to separate"<<endl; - cerr<<"scorers in the interpolated scorer)."<<endl; - cerr<<endl; - cerr<<"If you specify only one metric and one candidate file, only the final score"<<endl; - cerr<<"will be printed to stdout. Otherwise each line will contain metric name"<<endl; - cerr<<"and/or filename and the final score. Since most of the metrics prints some"<<endl; - cerr<<"debuging info, consider redirecting stderr to /dev/null."<<endl; + cerr << "usage: evaluator [options] --reference ref1[,ref2[,ref3...]] --candidate cand1[,cand2[,cand3...]] " << endl; + 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 << "[--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; + cerr << "[--rseed|-r] the random seed for bootstraping (defaults to system clock)" << endl; + cerr << "[--help|-h] print this message and exit" << endl; + cerr << endl; + cerr << "Evaluator is able to compute more metrics at once. To do this," << endl; + cerr << "separate scorers with semicolon (note that comma is used to separate" << endl; + cerr << "scorers in the interpolated scorer)." << endl; + cerr << endl; + cerr << "If you specify only one metric and one candidate file, only the final score" << endl; + cerr << "will be printed to stdout. Otherwise each line will contain metric name" << endl; + cerr << "and/or filename and the final score. Since most of the metrics prints some" << endl; + cerr << "debuging info, consider redirecting stderr to /dev/null." << endl; exit(1); } static struct option long_options[] = { - {"sctype",required_argument,0,'s'}, - {"scconfig",required_argument,0,'c'}, - {"reference",required_argument,0,'R'}, - {"candidate",required_argument,0,'C'}, - {"bootstrap",required_argument,0,'b'}, - {"rseed",required_argument,0,'r'}, - {"help",no_argument,0,'h'}, + {"sctype", required_argument, 0, 's'}, + {"scconfig", required_argument, 0, 'c'}, + {"reference", required_argument, 0, 'R'}, + {"candidate", required_argument, 0, 'C'}, + {"bootstrap", required_argument, 0, 'b'}, + {"rseed", required_argument, 0, 'r'}, + {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; int option_index; @@ -76,7 +75,7 @@ int main(int argc, char** argv) bool hasSeed = false; int c; - 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:h", long_options, &option_index)) != -1) { switch(c) { case 's': scorerType = string(optarg); @@ -119,13 +118,13 @@ int main(int argc, char** argv) vector<string> scorerTypes; if (reference.length() == 0) throw runtime_error("You have to specify at least one reference file."); - split(reference,',',refFiles); + split(reference, ',', refFiles); if (candidate.length() == 0) throw runtime_error("You have to specify at least one candidate file."); - split(candidate,',',candFiles); + split(candidate, ',', candFiles); if (scorerType.length() == 0) throw runtime_error("You have to specify at least one scorer."); - split(scorerType,';',scorerTypes); + split(scorerType, ';', scorerTypes); if (candFiles.size() > 1) g_has_more_files = true; if (scorerTypes.size() > 1) g_has_more_scorers = true; @@ -134,19 +133,17 @@ int main(int argc, char** argv) { for (vector<string>::const_iterator scorerIt = scorerTypes.begin(); scorerIt != scorerTypes.end(); ++scorerIt) { - g_scorer = ScorerFactory::getScorer(*scorerIt,scorerConfig); + g_scorer = ScorerFactory::getScorer(*scorerIt, scorerConfig); g_scorer->setReferenceFiles(refFiles); evaluate(*fileIt); delete g_scorer; } } - return EXIT_SUCCESS; } catch (const exception& e) { cerr << "Exception: " << e.what() << endl; return EXIT_FAILURE; } - } void evaluate(const string& candFile) @@ -199,9 +196,9 @@ void evaluate(const string& candFile) if (g_has_more_files) cout << candFile << "\t"; if (g_has_more_scorers) cout << g_scorer->getName() << "\t"; - cout.setf(ios::fixed,ios::floatfield); + cout.setf(ios::fixed, ios::floatfield); cout.precision(4); - cout << avg << "\t[" << lb << "," << rb << "]"<< endl; + cout << avg << "\t[" << lb << "," << rb << "]" << endl; } else { @@ -220,7 +217,7 @@ void evaluate(const string& candFile) if (g_has_more_files) cout << candFile << "\t"; if (g_has_more_scorers) cout << g_scorer->getName() << "\t"; - cout.setf(ios::fixed,ios::floatfield); + cout.setf(ios::fixed, ios::floatfield); cout.precision(4); cout << score << endl; } |