INNER CODE UNIT · Python
sortkey
IBM/transition-amr-parser · src/ibm_neural_aligner/main.py:386
def sortkey(edge):
s, y, t, a, b = edge
return (a, b)
for e in sorted(tree_edges, key=sortkey):
s, y, t, a, b = e
outoging_adjacency_graph[s].append(t)
assert (s, t) not in d_edge_labels
d_edge_labels[(s, t)] = y
# Render linearized parse as sequence of tokens and their token types.
# The token types are non-negative if corresponding to nodes, with value
# set to position in list of `node_ids`.
def render_tree(src):
assert src is not None
if src not in outoging_adjacency_graph:
node_name = amr.nodes[src]