diff options
author | Chris Dyer <cdyer@allegro.clab.cs.cmu.edu> | 2014-04-09 01:09:07 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@allegro.clab.cs.cmu.edu> | 2014-04-09 01:09:07 -0400 |
commit | d92457adef112e34e14c1ce9a43f95cf3c0da4d4 (patch) | |
tree | f6c535f0c1e52d80f332fa31662809f73ce9f453 /decoder/hg_union.cc | |
parent | a154f22c8ef2d170fa4a8179b1211898eb6831d3 (diff) |
better logging of union stats
Diffstat (limited to 'decoder/hg_union.cc')
-rw-r--r-- | decoder/hg_union.cc | 15 |
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); } |