diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-11 03:02:38 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-11 03:02:38 +0000 |
commit | 5b6a409e0818529ca4ac1c080bd091437eae2911 (patch) | |
tree | 26fd6f4fb8ed02b358ee7e757b7a30467316bf3f /decoder | |
parent | fd5351477569ab0db63b38aa2a2da3bbb2b2a1a6 (diff) |
cfg binarization compiles
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@515 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder')
-rwxr-xr-x | decoder/batched_append.h | 2 | ||||
-rwxr-xr-x | decoder/cfg.cc | 13 | ||||
-rwxr-xr-x | decoder/cfg.h | 1 |
3 files changed, 9 insertions, 7 deletions
diff --git a/decoder/batched_append.h b/decoder/batched_append.h index 745f567f..14a6d576 100755 --- a/decoder/batched_append.h +++ b/decoder/batched_append.h @@ -17,7 +17,7 @@ void batched_append_swap(Vector &v,SRange & s) { size_t i=v.size(); size_t news=i+s.size(); v.resize(news); - typename SRange::iterator_type si=s.begin(); + typename SRange::iterator si=s.begin(); for (;i<news;++i,++si) swap(v[i],*si); } diff --git a/decoder/cfg.cc b/decoder/cfg.cc index 74e23cb6..4149a1ce 100755 --- a/decoder/cfg.cc +++ b/decoder/cfg.cc @@ -10,9 +10,10 @@ using namespace std; namespace { -BinRhs nullrhs(std::numeric_limits<int>::min(),std::numeric_limits<int>::min()); +CFG::BinRhs nullrhs(std::numeric_limits<int>::min(),std::numeric_limits<int>::min()); } -WordID CFG::BinName(BinRhs const& b); + +WordID CFG::BinName(BinRhs const& b) { return TD::Convert(lexical_cast<string>(b.first)+"+"+lexical_cast<string>(b.second)); } @@ -37,8 +38,8 @@ void CFG::Binarize(CFGBinarize const& b) { BinRhs bin; for (NTs::const_iterator n=nts.begin(),nn=nts.end();n!=nn;++n) { NT const& nt=*n; - for (Ruleids::iterator ir=n.ruleids.begin(),er=n.ruleids.end();ir!=er;++ir) { - RHS &rhs=ir->rhs; // we're going to binarize this while adding newly created rules to new_... + for (Ruleids::const_iterator ir=nt.ruleids.begin(),er=nt.ruleids.end();ir!=er;++ir) { + RHS &rhs=rules[*ir].rhs; // we're going to binarize this while adding newly created rules to new_... if (rhs.empty()) continue; bin.second=rhs.back(); for (int r=rhs.size()-2;r>=rhsmin;--r) { // pairs from right to left (normally we leave the last pair alone) @@ -55,8 +56,8 @@ void CFG::Binarize(CFGBinarize const& b) { } } } - batch_append_swap(nts,new_nts); - batch_append_swap(rules,new_rules); + batched_append_swap(nts,new_nts); + batched_append_swap(rules,new_rules); } namespace { diff --git a/decoder/cfg.h b/decoder/cfg.h index 19d30f8b..e068e78b 100755 --- a/decoder/cfg.h +++ b/decoder/cfg.h @@ -48,6 +48,7 @@ struct CFG { struct Rule { // for binarizing - no costs/probs + Rule() { } Rule(int lhs,BinRhs const& binrhs) : lhs(lhs),rhs(2),p(1) { rhs[0]=binrhs.first; rhs[1]=binrhs.second; |