summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dyer <cdyer@allegro.clab.cs.cmu.edu>2014-04-09 01:09:07 -0400
committerChris Dyer <cdyer@allegro.clab.cs.cmu.edu>2014-04-09 01:09:07 -0400
commit5f3ec63bf30459d97ad9e61d4e9b3b734a4867bf (patch)
tree336636e0eaac28ffad049c0ea04d2b4d1a649f83
parent6b00a98deed65f8068bcc6f5b5bb3a3a7bd4cfa2 (diff)
better logging of union stats
-rw-r--r--decoder/hg_union.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/decoder/hg_union.cc b/decoder/hg_union.cc
index 4899e716..a659b6bc 100644
--- a/decoder/hg_union.cc
+++ b/decoder/hg_union.cc
@@ -7,6 +7,7 @@
namespace std { using std::tr1::unordered_set; }
#endif
+#include "verbose.h"
#include "hg.h"
#include "sparse_vector.h"
@@ -43,7 +44,7 @@ void Union(const Hypergraph& in, Hypergraph* out) {
abort();
}
if (out->nodes_.back().node_hash != in.nodes_.back().node_hash) {
- cerr << "Union: Goal nodes are mismatched!\n";
+ cerr << "Union: Goal nodes are mismatched!\n a=" << in.nodes_.back().node_hash << " b=" << out->nodes_.back().node_hash << "\n";
abort();
}
const int cgoal = out->nodes_.back().id_;
@@ -59,6 +60,8 @@ void Union(const Hypergraph& in, Hypergraph* out) {
}
}
+ double n_exists = 0;
+ double n_created = 0;
for (const auto& in_node : in.nodes_) {
HG::Node& out_node = out->nodes_[h2n[in_node.node_hash]];
for (const auto oeid : out_node.in_edges_) {
@@ -82,12 +85,20 @@ void Union(const Hypergraph& in, Hypergraph* out) {
t[i] = h2n[in.nodes_[in_edge.tail_nodes_[i]].node_hash];
HG::Edge* new_edge = out->AddEdge(in_edge, t);
out->ConnectEdgeToHeadNode(new_edge, &head);
+ ++n_created;
//cerr << "Created: " << new_edge->rule_->AsString() << " [head=" << new_edge->head_node_ << "]\n";
- } //else {
+ } else {
+ ++n_exists;
+ }
// cerr << "Not created: " << in.edges_[ieid].rule_->AsString() << "\n";
//}
}
}
+ if (!SILENT)
+ cerr << " Union: edges_created=" << n_created
+ << " edges_already_existing="
+ << n_exists << " ratio_new=" << (n_created / (n_exists + n_created))
+ << endl;
out->TopologicallySortNodesAndEdges(cgoal);
}