@@ -50,6 +50,8 @@ def parse_parser_results(text):
50
50
av = zip (* [av [2 :][x ::2 ] for x in (0 , 1 )])
51
51
# save as attr-value dict, convert numbers into ints
52
52
tmp ['words' ][av [1 ]] = dict (map (lambda x : (x [0 ], x [1 ].isdigit () and int (x [1 ]) or x [1 ]), av ))
53
+ # the results of this can't be serialized into JSON?
54
+ # tmp['words'][av[1]] = dict(map(lambda x: (x[0], x[1].isdigit() and int(x[1]) or x[1]), av))
53
55
state = 3
54
56
elif state == 3 :
55
57
# skip over parse tree
@@ -63,7 +65,7 @@ def parse_parser_results(text):
63
65
split_entry = re .split ("\(|, " , line [:- 1 ])
64
66
if len (split_entry ) == 3 :
65
67
rel , left , right = map (lambda x : remove_id (x ), split_entry )
66
- tmp ['tuples' ].append (( rel ,left ,right ))
68
+ tmp ['tuples' ].append (tuple ([ rel ,left ,right ] ))
67
69
print "\n " , rel , left , right
68
70
elif "Coreference links" in line :
69
71
state = 5
@@ -104,13 +106,17 @@ def __init__(self):
104
106
105
107
print "Starting the Stanford Core NLP parser."
106
108
# show progress bar while loading the models
107
- widgets = ['Loading Models: ' , Fraction (), ' ' , Bar (marker = RotatingMarker ()), ' ' , ETA ()]
109
+ self .state = "State of the parser"
110
+ widgets = ['Loading Models: ' , Fraction (), ' ' ,
111
+ Bar (marker = RotatingMarker ()), ' ' , self .state ]
108
112
pbar = ProgressBar (widgets = widgets , maxval = 5 , force_update = True ).start ()
109
113
self ._server .expect ("done." , timeout = 20 ) # Load pos tagger model (~5sec)
110
114
pbar .update (1 )
111
115
self ._server .expect ("done." , timeout = 200 ) # Load NER-all classifier (~33sec)
112
116
pbar .update (2 )
113
117
self ._server .expect ("done." , timeout = 600 ) # Load NER-muc classifier (~60sec)
118
+ self .state = "Loading CoNLL classifier"
119
+ widgets = ['Loading Models: ' , Fraction (), ' ' ,
114
120
pbar .update (3 )
115
121
self ._server .expect ("done." , timeout = 600 ) # Load CoNLL classifier (~50sec)
116
122
pbar .update (4 )
0 commit comments