diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-06 22:06:26 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-06 22:06:26 +0000 |
commit | 37070233d8768919bc70fa9bd8a33e04fbe661d3 (patch) | |
tree | ee5df3f276de4ce47432b0f7e9ee085600285eb3 /decoder | |
parent | 9f2f8c40c1e074ba08119dfb9ed55f278d6a51f2 (diff) |
prune epsilon, comments, use inside pruning for probably no segfaults in vest
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@167 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder')
-rw-r--r-- | decoder/hg.cc | 10 | ||||
-rw-r--r-- | decoder/hg.h | 1 |
2 files changed, 6 insertions, 5 deletions
diff --git a/decoder/hg.cc b/decoder/hg.cc index 19dbf892..b6b9d8bd 100644 --- a/decoder/hg.cc +++ b/decoder/hg.cc @@ -130,8 +130,8 @@ void Hypergraph::PushWeightsToGoal(double scale) { struct EdgeExistsWeightFunction { EdgeExistsWeightFunction(const std::vector<bool>& prunes) : prunes_(prunes) {} - double operator()(const Hypergraph::Edge& edge) const { - return (prunes_[edge.id_] ? 0.0 : 1.0); + bool operator()(const Hypergraph::Edge& edge) const { + return !prunes_[edge.id_]; } private: const vector<bool>& prunes_; @@ -147,8 +147,8 @@ void Hypergraph::PruneEdges(const std::vector<bool>& prune_edge, bool run_inside // I don't know a good c++ way to resolve this short of template specialization which // I dislike. If you know of a better way that doesn't involve specialization, // fix this! - vector<double> reachable; - bool goal_derivable = (0 < Inside<double, EdgeExistsWeightFunction>(*this, &reachable, wf)); + vector<Boolean> reachable; + bool goal_derivable = Inside/* <Boolean, EdgeExistsWeightFunction> */(*this, &reachable, wf); if (!goal_derivable) { edges_.clear(); nodes_.clear(); @@ -195,7 +195,7 @@ void Hypergraph_finish_prune(Hypergraph &hg,vector<prob_t> const& io,double cuto } if (verbose) cerr << "Finished pruning; removed " << pc << "/" << io.size() << " edges\n"; - hg.PruneEdges(prune); + hg.PruneEdges(prune,true); // inside reachability check in case cutoff rounded down too much (probably redundant with EPSILON hack) } void Hypergraph::DensityPruneInsideOutside(const double scale, diff --git a/decoder/hg.h b/decoder/hg.h index a632dc1c..e54b4bcc 100644 --- a/decoder/hg.h +++ b/decoder/hg.h @@ -166,6 +166,7 @@ class Hypergraph { // remove edges from the hypergraph if prune_edge[edge_id] is true // TODO need to investigate why this shouldn't be run for the forest trans // case. To investigate, change false to true and see where ftrans crashes + //TODO: what does the above "TODO" comment mean? that PruneEdges can lead to a crash? or that run_inside_algorithm should be false? there definitely is an unsolved bug, see hg.cc - workaround added void PruneEdges(const std::vector<bool>& prune_edge, bool run_inside_algorithm = false); // for density>=1.0, keep this many times the edges needed for the 1best derivation |