From 704052fecfb16f2e9074bace99936a566f9d84ab Mon Sep 17 00:00:00 2001 From: graehl Date: Tue, 6 Jul 2010 18:11:34 +0000 Subject: epsilon distance for pruning - should alter density git-svn-id: https://ws10smt.googlecode.com/svn/trunk@159 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/hg.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/decoder/hg.cc b/decoder/hg.cc index 7fc9643d..50f61865 100644 --- a/decoder/hg.cc +++ b/decoder/hg.cc @@ -177,6 +177,8 @@ void Hypergraph::PruneEdges(const std::vector& prune_edge, bool run_inside void Hypergraph_finish_prune(Hypergraph &hg,vector const& io,double cutoff,vector const* preserve_mask,bool verbose=false) { + const double EPSILON=1e-5; + cutoff=cutoff-EPSILON; // vector prune(hg.NumberOfEdges()); if (verbose) { if (preserve_mask) cerr << preserve_mask->size() << " " << prune.size() << endl; @@ -210,9 +212,10 @@ void Hypergraph::DensityPruneInsideOutside(const double scale, return; } vector io(edges_.size()); - if (use_sum_prod_semiring) + if (use_sum_prod_semiring) { ComputeEdgePosteriors(scale, &io); - else + assert(scale > 0.0); + } else ComputeBestPathThroughEdges(&io); assert(edges_.size() == io.size()); vector sorted = io; @@ -225,12 +228,12 @@ void Hypergraph::BeamPruneInsideOutside( const bool use_sum_prod_semiring, const double alpha, const vector* preserve_mask) { - assert(alpha > 0.0); - assert(scale > 0.0); + assert(alpha >= 0.0); vector io(edges_.size()); - if (use_sum_prod_semiring) + if (use_sum_prod_semiring) { ComputeEdgePosteriors(scale, &io); - else + assert(scale > 0.0); + } else ComputeBestPathThroughEdges(&io); assert(edges_.size() == io.size()); prob_t best; // initializes to zero -- cgit v1.2.3