summaryrefslogtreecommitdiff
path: root/decoder/hg_io.cc
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-07-29 21:04:14 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2012-07-29 21:04:14 -0400
commitc7d1b04980d9d90458625a7f8e92985c7409a78d (patch)
tree60dfa6bffc1a88af199cc5d456d9bba8aefd1107 /decoder/hg_io.cc
parentfd5e2c6858c7522917d6498bdb074b6d03cbacf2 (diff)
fix grammar converter to remove edges that cannot exist in any valid derivation
Diffstat (limited to 'decoder/hg_io.cc')
-rw-r--r--decoder/hg_io.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/decoder/hg_io.cc b/decoder/hg_io.cc
index bfb2fb80..8bd40387 100644
--- a/decoder/hg_io.cc
+++ b/decoder/hg_io.cc
@@ -261,6 +261,7 @@ static void WriteRule(const TRule& r, ostream* out) {
}
bool HypergraphIO::WriteToJSON(const Hypergraph& hg, bool remove_rules, ostream* out) {
+ if (hg.empty()) { *out << "{}\n"; return true; }
map<const TRule*, int> rid;
ostream& o = *out;
rid[NULL] = 0;