@@ -38,7 +38,7 @@ def parse_parser_results(text):
38
38
elif state == 2 :
39
39
if not line .startswith ("[Text=" ):
40
40
print line
41
- raise Exception ("Parse error" )
41
+ raise Exception ("Parse error. Could not find [Text= " )
42
42
tmp ['words' ] = {}
43
43
exp = re .compile ('\[([a-zA-Z0-9=. ]+)\]' )
44
44
m = exp .findall (line )
@@ -54,8 +54,9 @@ def parse_parser_results(text):
54
54
tmp ['tuples' ] = []
55
55
if state == 4 :
56
56
# dependency parse
57
- if not line .startswith (" " ) and line .rstrip ().endswith (")" ):
58
- split_entry = re .split ("\(|, " , line [:- 2 ])
57
+ line = line .rstrip ()
58
+ if not line .startswith (" " ) and line .endswith (")" ):
59
+ split_entry = re .split ("\(|, " , line [:- 1 ])
59
60
if len (split_entry ) == 3 :
60
61
rel , left , right = map (lambda x : remove_id (x ), split_entry )
61
62
tmp ['tuples' ].append ((rel ,left ,right ))
@@ -119,11 +120,13 @@ def parse(self, text):
119
120
"""
120
121
print "Request" , text
121
122
print self ._server .sendline (text )
122
- end_time = time .time () + 2
123
+ max_expected_time = 2 + len (text ) / 200.0
124
+ print "Timeout" , max_expected_time
125
+ end_time = time .time () + max_expected_time
123
126
incoming = ""
124
127
while True :
125
- # Still have time left, so read more data
126
- ch = self ._server .read_nonblocking (2000 , 3 )
128
+ # Time left, read more data
129
+ ch = self ._server .read_nonblocking (2000 , max_expected_time )
127
130
freshlen = len (ch )
128
131
time .sleep (0.0001 )
129
132
incoming = incoming + ch
0 commit comments