From 667675465486e1f9729931c0b38b5a1124a1c000 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/hg_cfg.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 decoder/hg_cfg.h (limited to 'decoder/hg_cfg.h') diff --git a/decoder/hg_cfg.h b/decoder/hg_cfg.h new file mode 100755 index 00000000..0a3eb53c --- /dev/null +++ b/decoder/hg_cfg.h @@ -0,0 +1,42 @@ +#ifndef HG_CFG_H +#define HG_CFG_H + +#include "cfg.h" + +class Hypergraph; + +// in case you might want the CFG whether or not you apply FSA models: +struct HgCFG { + HgCFG(Hypergraph const& ih) : ih(ih) { have_cfg=binarized=false; } + Hypergraph const& ih; + CFG cfg; + bool have_cfg; + void InitCFG(CFG &to) { + to.Init(ih,true,false,true); + } + bool binarized; + CFG &GetCFG() + { + if (!have_cfg) { + have_cfg=true; + InitCFG(cfg); + } + return cfg; + } + void GiveCFG(CFG &to) { + if (!have_cfg) + InitCFG(to); + else { + have_cfg=false; + to.Clear(); + to.Swap(cfg); + } + } + CFG const& GetCFG() const { + assert(have_cfg); + return cfg; + } +}; + + +#endif -- cgit v1.2.3