From 190f68c880eb27506669e95e2bc0493e2ec42c4c Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Sun, 17 Aug 2014 07:51:16 +0100 Subject: functional again --- util/cdec2json.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'util/cdec2json.py') diff --git a/util/cdec2json.py b/util/cdec2json.py index adddb64..e7c8e93 100755 --- a/util/cdec2json.py +++ b/util/cdec2json.py @@ -15,13 +15,6 @@ def hg2json(hg, weights): """ res = '' res += "{\n" - res += '"weights":{'+"\n" - a = [] - for i in weights: - if i[1] != 0: - a.append( '"%s":%s'%(i[0], i[1]) ) - res += ", ".join(a)+"\n" - res += "},\n" res += '"rules":[\n' rules = [] for i in hg.edges: @@ -35,9 +28,9 @@ def hg2json(hg, weights): res += '"nodes":'+"\n" res += "[\n" a = [] - a.append( '{ "id":0, "cat":"root", "span":[-1,-1] }' ) + a.append( '{ "id":0, "symbol":"root", "span":[-1,-1] }' ) for i in hg.nodes: - a.append('{ "id":%d, "cat":"%s", "span":[%d,%d] }'%(i.id+1, i.cat, i.span[0], i.span[1])) + a.append('{ "id":%d, "symbol":"%s", "span":[%d,%d] }'%(i.id+1, i.cat, i.span[0], i.span[1])) res += ",\n".join(a)+"\n" res += "],\n" res += '"edges":'+"\n" -- cgit v1.2.3