From fa45c8489b2f016766a7a946eb7ba2b9140749ed Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Thu, 24 Mar 2011 16:37:06 -0400 Subject: more augment grammar options --- training/augment_grammar.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'training/augment_grammar.cc') diff --git a/training/augment_grammar.cc b/training/augment_grammar.cc index 9ad03b6c..df8d4ee8 100644 --- a/training/augment_grammar.cc +++ b/training/augment_grammar.cc @@ -35,6 +35,7 @@ bool InitCommandLine(int argc, char** argv, po::variables_map* conf) { opts.add_options() ("source_lm,l",po::value(),"Source language LM (KLM)") ("collapse_weights,w",po::value(), "Collapse weights into a single feature X using the coefficients from this weights file") + ("clear_features_after_collapse,c", "After collapse_weights, clear the features except for X") ("add_shape_types,s", "Add rule shape types") ("extra_lex_feature,x", "Experimental nonlinear lexical weighting feature") ("replace_files,r", "Replace files with transformed variants (requires loading full grammar into memory)") @@ -90,6 +91,7 @@ bool extra_feature; int kSrcLM; vector col_weights; bool gather_rules; +bool clear_features = false; vector rules; static void RuleHelper(const TRulePtr& new_rule, const unsigned int ctf_level, const TRulePtr& coarse_rule, void* extra) { @@ -107,7 +109,7 @@ static void RuleHelper(const TRulePtr& new_rule, const unsigned int ctf_level, c } if (col_weights.size()) { double score = r->scores_.dot(col_weights); - r->scores_.clear(); + if (clear_features) r->scores_.clear(); r->scores_.set_value(kX, score); } if (gather_rules) { @@ -136,6 +138,7 @@ int main(int argc, char** argv) { w.InitFromFile(conf["collapse_weights"].as()); w.InitVector(&col_weights); } + clear_features = conf.count("clear_features_after_collapse") > 0; gather_rules = false; bool replace_files = conf.count("replace_files"); if (replace_files) gather_rules = true; -- cgit v1.2.3