-
Notifications
You must be signed in to change notification settings - Fork 1
/
writeParses.py
30 lines (24 loc) · 1.04 KB
/
writeParses.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from Hogwash import Session #main hogwash class
from Hogwash.Results import ResultsFile #type for file created by hw job
from Hogwash.Action import Action #supertype for runnable objects
from Hogwash.Errors import BadExitCode #error if the program crashed
from waterworks.Processes import bettersystem #run an external command
import sys
from path import path
import os
from shutil import copy
from iterextras import batch
from StringIO import StringIO #store output of process
from distributedParser import Parse
from topdownParser import Parser, Grammar, treeToStr, normalizeTree
if __name__ == "__main__":
session = Session(sys.argv[1], read_only=True, verbose=0)
p = Parser(Grammar({}))
for job in session[:100]:
if job.status != "finished":
sent = job.args[0].sentence
fail = p.parseFail(sent)
print treeToStr(normalizeTree(fail.tree(), unbinarize=True))
else:
print treeToStr(normalizeTree(job.results, unbinarize=False),
epsilonSym="EPSILON")