Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 55 lines (49 sloc) 0.932 kB
6676754 CFG binarize opts
graehl authored
1 #ifndef HG_CFG_H
2 #define HG_CFG_H
3
4 #include "cfg.h"
5
6 class Hypergraph;
7
8 // in case you might want the CFG whether or not you apply FSA models:
9 struct HgCFG {
8ff664a still compiles
graehl authored
10 void set_defaults() {
6d3cf2f really fixed binarization. test
graehl@gmail.com authored
11 have_cfg=binarized=have_features=uniqed=false;
8ff664a still compiles
graehl authored
12 want_features=true;
13 }
14 HgCFG(Hypergraph const& ih) : ih(ih) {
15 set_defaults();
6d3cf2f really fixed binarization. test
graehl@gmail.com authored
16 }
6676754 CFG binarize opts
graehl authored
17 Hypergraph const& ih;
18 CFG cfg;
19 bool have_cfg;
541915b cfg test
graehl@gmail.com authored
20 bool have_features;
21 bool want_features;
6676754 CFG binarize opts
graehl authored
22 void InitCFG(CFG &to) {
541915b cfg test
graehl@gmail.com authored
23 to.Init(ih,true,want_features,true);
6676754 CFG binarize opts
graehl authored
24 }
25 bool binarized;
6d3cf2f really fixed binarization. test
graehl@gmail.com authored
26 bool uniqed;
6676754 CFG binarize opts
graehl authored
27 CFG &GetCFG()
28 {
29 if (!have_cfg) {
30 have_cfg=true;
31 InitCFG(cfg);
32 }
33 return cfg;
34 }
35 void GiveCFG(CFG &to) {
36 if (!have_cfg)
37 InitCFG(to);
38 else {
8ff664a still compiles
graehl authored
39 cfg.VisitRuleIds(*this);
6676754 CFG binarize opts
graehl authored
40 have_cfg=false;
41 to.Clear();
8ff664a still compiles
graehl authored
42 swap(to,cfg);
6676754 CFG binarize opts
graehl authored
43 }
44 }
8ff664a still compiles
graehl authored
45 void operator()(int ri) const {
46 }
6676754 CFG binarize opts
graehl authored
47 CFG const& GetCFG() const {
48 assert(have_cfg);
49 return cfg;
50 }
51 };
52
53
54 #endif
Something went wrong with that request. Please try again.