8000 fixed parse_imperative · antonini/stanford-corenlp-python@1da4e46 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1da4e46

Browse files
committed
fixed parse_imperative
1 parent 5235f07 commit 1da4e46

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

corenlp.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ def parse_parser_results(text):
5050
av = re.split("=| ", s)
5151
# make [ignore,ignore,a,b,c,d] into [[a,b],[c,d]]
5252
# and save as attr-value dict, convert numbers into ints
53-
tmp['words'][av[1]] = dict(zip(*[av[2:][x::2] for x in (0, 1)]))
54-
# the results of this can't be serialized into JSON?
53+
tmp['words'].append((av[1], dict(zip(*[av[2:][x::2] for x in (0, 1)])))
54+
# tried to convert digits to ints instead of strings, but
55+
# it seems the results of this can't be serialized into JSON?
5556
# av = zip(*[av[2:][x::2] for x in (0, 1)])
5657
# tmp['words'][av[1]] = dict(map(lambda x: (x[0], x[1].isdigit() and int(x[1]) or x[1]), av))
5758
state = 3
@@ -191,11 +192,11 @@ def parse_imperative(self, text):
191192
if not used_pronoun:
192193
return self.parse(text)
193194

194-
text = used_pronoun+" "+text.lstrip()
195+
new_text = used_pronoun+" "+text.lstrip()
195196
first_word = ""
196-
if len(text.split()) > 1:
197-
first_word = text.split()[1]
198-
result = self._parse(text)
197+
if len(text.split()) > 0:
198+
first_word = text.split()[0]
199+
result = self._parse(new_text)
199200
if result[0].has_key('text'):
200201
result[0]['text'] = text
201202
result[0]['tuples'] = filter(lambda x: not (x[1] == used_pronoun or x[2]

0 commit comments

Comments
 (0)
0