summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-06 18:11:34 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-06 18:11:34 +0000
commit503146bfdf99682ce81366b0134f3196e0a4e32c (patch)
treeb1c2574cdae95cc02421f75699bd05c52fd8cce7
parent9087ecf10e76908a5aafbc81b29a6388344af1ab (diff)
epsilon distance for pruning - should alter density
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@159 ec762483-ff6d-05da-a07a-a48fb63a330f
-rw-r--r--decoder/hg.cc15
1 files 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<bool>& prune_edge, bool run_inside
void Hypergraph_finish_prune(Hypergraph &hg,vector<prob_t> const& io,double cutoff,vector<bool> const* preserve_mask,bool verbose=false)
{
+ const double EPSILON=1e-5;
+ cutoff=cutoff-EPSILON; //
vector<bool> 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<prob_t> 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<prob_t> sorted = io;
@@ -225,12 +228,12 @@ void Hypergraph::BeamPruneInsideOutside(
const bool use_sum_prod_semiring,
const double alpha,
const vector<bool>* preserve_mask) {
- assert(alpha > 0.0);
- assert(scale > 0.0);
+ assert(alpha >= 0.0);
vector<prob_t> 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