From 7b9c1f91e594c4b7783c72e4516d59d60a04dc91 Mon Sep 17 00:00:00 2001 From: graehl Date: Mon, 12 Jul 2010 03:42:47 +0000 Subject: DEBUG_PROMISE - looks ok git-svn-id: https://ws10smt.googlecode.com/svn/trunk@220 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/apply_models.cc | 5 +++-- decoder/ff_lm.cc | 3 ++- decoder/hg.cc | 15 +++++++++++---- decoder/hg.h | 2 ++ 4 files changed, 18 insertions(+), 7 deletions(-) (limited to 'decoder') diff --git a/decoder/apply_models.cc b/decoder/apply_models.cc index 4093f667..240bd12b 100644 --- a/decoder/apply_models.cc +++ b/decoder/apply_models.cc @@ -414,8 +414,9 @@ void ApplyModelSet(const Hypergraph& in, ma.Apply(); } else if (config.algorithm == 1) { int pl = config.pop_limit; - if (pl > 100 && in.nodes_.size() > 80000) { - pl = 30; + const int max_pl_for_large=50; + if (pl > max_pl_for_large && in.nodes_.size() > 80000) { + pl = max_pl_for_large; cerr << " Note: reducing pop_limit to " << pl << " for very large forest\n"; } CubePruningRescorer ma(models, smeta, in, pl, out); diff --git a/decoder/ff_lm.cc b/decoder/ff_lm.cc index 0590fa7e..5de9c321 100644 --- a/decoder/ff_lm.cc +++ b/decoder/ff_lm.cc @@ -465,7 +465,8 @@ LanguageModelImpl *make_lm_impl(int order, string const& f, int load_order) return new ReuseLMI(order,ngs.get(f)); } else { LanguageModelImpl *r=new LanguageModelImpl(order,f,load_order); - ngs.add(f,r->get_lm()); + if (!load_order || !ngs.have(f)) + ngs.add(f,r->get_lm()); return r; } } diff --git a/decoder/hg.cc b/decoder/hg.cc index b017b183..0a257092 100644 --- a/decoder/hg.cc +++ b/decoder/hg.cc @@ -192,16 +192,23 @@ void Hypergraph::SetPromise(NodeProbs const& inside,NodeProbs const& outside,dou if (!nn) return; assert(inside.size()==nn); assert(outside.size()==nn); - double sum; //TODO: prevent underflow by using prob_t? + double sum=0; //TODO: prevent underflow by using prob_t? if (normalize) for (int i=0;i0); assert(!use_density||density>=1); assert(!use_sum_prod_semiring||scale>0); - int rnum; + int rnum=edges_.size(); if (use_density) { const int plen = ViterbiPathLength(*this); vector bp; - rnum = min(static_cast(edges_.size()), static_cast(density * static_cast(plen))); + rnum = min(rnum, static_cast(density * static_cast(plen))); cerr << "Density pruning: keep "<=1.0, keep this many times the edges needed for the 1best derivation // worse than the score of the global best past (or the highest edge posterior) -- cgit v1.2.3