diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-10 23:49:33 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-10 23:49:33 +0000 |
commit | 667675465486e1f9729931c0b38b5a1124a1c000 (patch) | |
tree | 731cbe983050220b995c643421beb04b4e271560 /decoder/cfg_options.h | |
parent | 131c2280809e890a817688b708f03a231025fd77 (diff) |
CFG binarize opts
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@503 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/cfg_options.h')
-rwxr-xr-x | decoder/cfg_options.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/decoder/cfg_options.h b/decoder/cfg_options.h new file mode 100755 index 00000000..bc7fed5f --- /dev/null +++ b/decoder/cfg_options.h @@ -0,0 +1,49 @@ +#ifndef CFG_OPTIONS_H +#define CFG_OPTIONS_H + +#include "hg_cfg.h" +#include "cfg_format.h" +#include "cfg_binarize.h" +//#include "program_options.h" + +struct CFGOptions { + CFGFormat format; + CFGBinarize binarize; + std::string cfg_output; + void set_defaults() { + format.set_defaults(); + binarize.set_defaults(); + cfg_output=""; + } + CFGOptions() { set_defaults(); } + template <class Opts> // template to support both printable_opts and boost nonprintable + void AddOptions(Opts *opts) { + opts->add_options() + ("cfg_output", defaulted_value(&cfg_output),"write final target CFG (before FSA rescorinn) to this file") + ; + binarize.AddOptions(opts); + format.AddOptions(opts); + } + void Validate() { + format.Validate(); + binarize.Validate(); + } + char const* description() const { + return "CFG output options"; + } + void maybe_output(HgCFG &hgcfg) { + if (cfg_output.empty()) return; + WriteFile o(cfg_output); + maybe_binarize(hgcfg); + hgcfg.GetCFG().Print(o.get(),format); + } + void maybe_binarize(HgCFG &hgcfg) { + if (hgcfg.binarized) return; + hgcfg.GetCFG().Binarize(binarize); + hgcfg.binarized=true; + } + +}; + + +#endif |