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 | 46dd30c7d4da68b83ebfd5975153521ee237311f (patch) | |
tree | aba07e1f24639c56b341393880b67987b08854da /decoder/cfg_options.h | |
parent | 0fec6f37266ecbaf6f72d2f3d7e652c78004af17 (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 |