diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-11 01:02:02 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-11 01:02:02 +0000 |
commit | 916944c8f234cbd4bdc06e5079f678f1835df426 (patch) | |
tree | 03920fa4a5c58c0eda68f0d1693b4fa289b749e1 /decoder | |
parent | 49eb2dddac93654388d4a889414dc10db1fb8998 (diff) |
only print cfg once
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@505 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder')
-rw-r--r-- | decoder/cdec.cc | 5 | ||||
-rwxr-xr-x | decoder/cfg_format.h | 24 | ||||
-rwxr-xr-x | decoder/cfg_options.h | 1 |
3 files changed, 24 insertions, 6 deletions
diff --git a/decoder/cdec.cc b/decoder/cdec.cc index b5d768e8..9696fb69 100644 --- a/decoder/cdec.cc +++ b/decoder/cdec.cc @@ -661,11 +661,6 @@ int main(int argc, char** argv) { HgCFG hgcfg(forest); 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:"); if (!has_late_models) diff --git a/decoder/cfg_format.h b/decoder/cfg_format.h index 10361804..1066c510 100755 --- a/decoder/cfg_format.h +++ b/decoder/cfg_format.h @@ -1,6 +1,7 @@ #ifndef CFG_FORMAT_H #define CFG_FORMAT_H +#include <iostream> #include <string> #include "wordid.h" #include "feature_vector.h" @@ -31,6 +32,26 @@ struct CFGFormat { ("nt_span",defaulted_value(&nt_span),"prefix A(i,j) for NT coming from hypergraph node with category A on span [i,j). this is after --nt_prefix if any") ; } + + void print(std::ostream &o) const { + o<<"["; + if (identity_scfg) + o<<"Identity SCFG "; + if (features) + o<<"+Features "; + if (logprob_feat) + o<<logprob_feat_name<<"(logprob) "; + if (nt_span) + o<<"named-NTs "; + if (cfg_comma_nt) + o<<",N "; + o << "CFG output format"; + o<<"]"; + } + friend inline std::ostream &operator<<(std::ostream &o,CFGFormat const& me) { + me.print(o); return o; + } + void Validate() { } template<class CFG> void print_source_nt(std::ostream &o,CFG const&cfg,int id,int position=1) const { @@ -43,7 +64,8 @@ struct CFGFormat { template <class CFG> void print_nt_name(std::ostream &o,CFG const& cfg,int id) const { o<<nt_prefix; - cfg.print_nt_name(o,id); + if (nt_span) + cfg.print_nt_name(o,id); o<<id; } diff --git a/decoder/cfg_options.h b/decoder/cfg_options.h index bc7fed5f..cbbe3b42 100755 --- a/decoder/cfg_options.h +++ b/decoder/cfg_options.h @@ -33,6 +33,7 @@ struct CFGOptions { } void maybe_output(HgCFG &hgcfg) { if (cfg_output.empty()) return; + std::cerr<<"Printing CFG to "<<cfg_output<<": "<<format<<'\n'; WriteFile o(cfg_output); maybe_binarize(hgcfg); hgcfg.GetCFG().Print(o.get(),format); |