diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-11 02:46:13 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-11 02:46:13 +0000 |
commit | 82384b4ec365f3d2ad2c9bca078a0b38d4be09c0 (patch) | |
tree | f6f015f2791ec9b1ec94c90c98b09c0d251aee9e /decoder/cfg.h | |
parent | e4e66118c14704509e214aa32689ef304ae5ada2 (diff) |
merge
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@511 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/cfg.h')
-rwxr-xr-x | decoder/cfg.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/decoder/cfg.h b/decoder/cfg.h index a390ece9..19d30f8b 100755 --- a/decoder/cfg.h +++ b/decoder/cfg.h @@ -27,6 +27,7 @@ //#include "int_or_pointer.h" #include "small_vector.h" #include "nt_span.h" +#include <algorithm> class Hypergraph; class CFGFormat; // #include "cfg_format.h" @@ -42,7 +43,16 @@ struct CFG { o << nts[n].from; } + typedef std::pair<int,int> BinRhs; + WordID BinName(BinRhs const& b); + struct Rule { + // for binarizing - no costs/probs + Rule(int lhs,BinRhs const& binrhs) : lhs(lhs),rhs(2),p(1) { + rhs[0]=binrhs.first; + rhs[1]=binrhs.second; + } + int lhs; // index into nts RHS rhs; prob_t p; // h unused for now (there's nothing admissable, and p is already using 1st pass inside as pushed toward top) @@ -50,11 +60,26 @@ struct CFG { #if CFG_DEBUG TRulePtr rule; // normally no use for this (waste of space) #endif + void Swap(Rule &o) { + using namespace std; + swap(lhs,o.lhs); + swap(rhs,o.rhs); + swap(p,o.p); + swap(f,o.f); +#if CFG_DEBUG + swap(rule,o.rule); +#endif + } }; struct NT { Ruleids ruleids; // index into CFG rules with lhs = this NT. aka in_edges_ NTSpan from; // optional name - still needs id to disambiguate + void Swap(NT &o) { + using namespace std; + swap(ruleids,o.ruleids); + swap(from,o.from); + } }; CFG() : hg_() { uninit=true; } @@ -92,5 +117,9 @@ protected: int goal_nt; }; +inline void swap(CFG &a,CFG &b) { + a.Swap(b); +} + #endif |