summaryrefslogtreecommitdiff
path: root/decoder/oracle_bleu.h
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-18 23:33:03 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-18 23:33:03 +0000
commit9b2da83a560931baab56b73214793b8b664a2689 (patch)
tree942059838fe820527f6df942c38b822b6cf88eab /decoder/oracle_bleu.h
parent241a0317966f00546aaf3b5c02c137097cfaccda (diff)
boost cmd line notify(conf) was missing
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@313 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/oracle_bleu.h')
-rwxr-xr-xdecoder/oracle_bleu.h37
1 files changed, 25 insertions, 12 deletions
diff --git a/decoder/oracle_bleu.h b/decoder/oracle_bleu.h
index cc19fbca..07d83b7f 100755
--- a/decoder/oracle_bleu.h
+++ b/decoder/oracle_bleu.h
@@ -73,13 +73,13 @@ struct OracleBleu {
WeightVector feature_weights_;
DocScorer ds;
- static void AddOptions(boost::program_options::options_description *opts) {
+ void AddOptions(boost::program_options::options_description *opts) {
using namespace boost::program_options;
using namespace std;
opts->add_options()
- ("references,R", value<Refs >(), "Translation reference files")
- ("oracle_loss", value<string>(), "IBM_BLEU_3 (default), IBM_BLEU etc")
- ("bleu_weight", value<double>()->default_value(1.), "weight to give the hope/fear loss function vs. model score")
+ ("references,R", value<Refs >(&refs), "Translation reference files")
+ ("oracle_loss", value<string>(&loss_name)->default_value("IBM_BLEU_3"), "IBM_BLEU_3 (default), IBM_BLEU etc")
+ ("bleu_weight", value<double>(&bleu_weight)->default_value(1.), "weight to give the hope/fear loss function vs. model score")
;
}
int order;
@@ -110,28 +110,41 @@ struct OracleBleu {
}
double bleu_weight;
- void UseConf(boost::program_options::variables_map const& conf) {
+ // you have to call notify(conf) yourself, once, in main or similar
+ void UseConf(boost::program_options::variables_map const& /* conf */) {
using namespace std;
- bleu_weight=conf["bleu_weight"].as<double>();
- set_loss(conf["oracle_loss"].as<string>());
- set_refs(conf["references"].as<Refs>());
+ // bleu_weight=conf["bleu_weight"].as<double>();
+ //set_loss(conf["oracle_loss"].as<string>());
+ //set_refs(conf["references"].as<Refs>());
+ init_loss();
+ init_refs();
}
ScoreType loss;
-// std::string loss_name;
+ std::string loss_name;
boost::shared_ptr<FeatureFunction> pff;
- void set_loss(std::string const& lossd="IBM_BLEU_3") {
-// loss_name=lossd;
- loss=ScoreTypeFromString(lossd);
+ void set_loss(std::string const& lossd) {
+ loss_name=lossd;
+ init_loss();
+ }
+ void init_loss() {
+ loss=ScoreTypeFromString(loss_name);
order=(loss==IBM_BLEU_3)?3:4;
std::ostringstream param;
param<<"-o "<<order;
pff=global_ff_registry->Create("BLEUModel",param.str());
}
+ bool is_null() const {
+ return refs.empty();
+ }
void set_refs(Refs const& r) {
refs=r;
+ init_refs();
+ }
+ void init_refs() {
+ if (is_null()) return;
assert(refs.size());
ds=DocScorer(loss,refs);
doc_score.reset();