Created
October 28, 2015 02:42
-
-
Save jtauber/676c7030d9b56f3e6acf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
lines = [] | |
parent_by_id = {} | |
rel_by_id = {} | |
with open(sys.argv[1]) as f: | |
for line in f: | |
word_id, text, parent, rel = line.strip().split() | |
lines.append((word_id, text, parent, rel)) | |
parent_by_id[word_id] = parent | |
rel_by_id[word_id] = rel | |
for line in lines: | |
word_id, text, parent, rel = line | |
while parent != 'None': | |
rel += "-" + rel_by_id[parent] | |
parent = parent_by_id[parent] | |
print(word_id, text, rel) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment