From 46dd30c7d4da68b83ebfd5975153521ee237311f Mon Sep 17 00:00:00 2001 From: graehl Date: Tue, 10 Aug 2010 23:49:33 +0000 Subject: CFG binarize opts git-svn-id: https://ws10smt.googlecode.com/svn/trunk@503 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/cdec.cc | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'decoder/cdec.cc') diff --git a/decoder/cdec.cc b/decoder/cdec.cc index a179e029..b5d768e8 100644 --- a/decoder/cdec.cc +++ b/decoder/cdec.cc @@ -37,7 +37,9 @@ #include "../vest/scorer.h" #include "apply_fsa_models.h" #include "program_options.h" -#include "cfg_format.h" +#include "cfg_options.h" + +CFGOptions cfg_options; using namespace std; using namespace std::tr1; @@ -62,7 +64,6 @@ void ConvertSV(const SparseVector& src, SparseVector* trg) { trg->set_value(it->first, it->second); } - inline string str(char const* name,po::variables_map const& conf) { return conf[name].as(); } @@ -106,9 +107,6 @@ void print_options(std::ostream &out,po::options_description const& opts) { out << '"'; } - -CFGFormat cfgf; - void InitCommandLine(int argc, char** argv, OracleBleu &ob, po::variables_map* confp) { po::variables_map &conf=*confp; po::options_description opts("Configuration options"); @@ -172,10 +170,8 @@ void InitCommandLine(int argc, char** argv, OracleBleu &ob, po::variables_map* c ("forest_output,O",po::value(),"Directory to write forests to") ("minimal_forests,m","Write minimal forests (excludes Rule information). Such forests can be used for ML/MAP training, but not rescoring, etc."); ob.AddOptions(&opts); - po::options_description cfgo("CFG output options"); - cfgo.add_options() - ("cfg_output", po::value(),"write final target CFG (before FSA rescorinn) to this file"); - cfgf.AddOptions(&cfgo); + po::options_description cfgo(cfg_options.description()); + cfg_options.AddOptions(&cfgo); po::options_description clo("Command line options"); clo.add_options() ("config,c", po::value >(), "Configuration file(s) - latest has priority") @@ -555,6 +551,7 @@ int main(int argc, char** argv) { const bool crf_uniform_empirical = conf.count("crf_uniform_empirical"); const bool get_oracle_forest = conf.count("get_oracle_forest"); + cfg_options.Validate(); if (get_oracle_forest) oracle.UseConf(conf); @@ -663,9 +660,11 @@ int main(int argc, char** argv) { maybe_prune(forest,conf,"beam_prune","density_prune","+LM",srclen); HgCFG hgcfg(forest); - if (conf.count("cfg_output")) { - WriteFile o(str("cfg_output",conf)); - hgcfg.GetCFG().Print(o.get(),cfgf); + cfg_options.maybe_output(hgcfg); + if (!cfg_options.cfg_output.empty()) { + WriteFile o(cfg_options.cfg_output); + CFG &cfg=hgcfg.GetCFG(); + cfg.Print(o.get(),cfg_options.format); } if (!fsa_ffs.empty()) { Timer t("Target FSA rescoring:"); -- cgit v1.2.3