From 5b6a409e0818529ca4ac1c080bd091437eae2911 Mon Sep 17 00:00:00 2001 From: graehl Date: Wed, 11 Aug 2010 03:02:38 +0000 Subject: cfg binarization compiles git-svn-id: https://ws10smt.googlecode.com/svn/trunk@515 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/batched_append.h | 2 +- decoder/cfg.cc | 13 +++++++------ decoder/cfg.h | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'decoder') 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::min(),std::numeric_limits::min()); +CFG::BinRhs nullrhs(std::numeric_limits::min(),std::numeric_limits::min()); } -WordID CFG::BinName(BinRhs const& b); + +WordID CFG::BinName(BinRhs const& b) { return TD::Convert(lexical_cast(b.first)+"+"+lexical_cast(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; -- cgit v1.2.3