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 | dd018163ca8236d587a4899436a3bdea29b95564 (patch) | |
tree | f0ee0d4cb3eda2eb140a3e0a7edb662888a8ad70 | |
parent | 7c557a1191730fba6b87ff8a94c7429aff5940b7 (diff) |
cfg binarization compiles
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@515 ec762483-ff6d-05da-a07a-a48fb63a330f
-rwxr-xr-x | decoder/batched_append.h | 2 | ||||
-rwxr-xr-x | decoder/cfg.cc | 13 | ||||
-rwxr-xr-x | decoder/cfg.h | 1 | ||||
-rw-r--r-- | utils/small_vector.h | 2 |
4 files changed, 10 insertions, 8 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; diff --git a/utils/small_vector.h b/utils/small_vector.h index ae1e5727..077a524a 100644 --- a/utils/small_vector.h +++ b/utils/small_vector.h @@ -246,7 +246,7 @@ public: return !(a==b); } - void swap(Self& o) const { + void swap(Self& o) { swap_pod(*this,o); } |