8000 docs · apercis/stanford-corenlp-python@dea8522 · GitHub
[go: up one dir, main page]

Skip to content

Commit dea8522

Browse files
committed
docs
1 parent 87c8573 commit dea8522

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

server.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def parse_parser_results(text):
5050
av = zip(*[av[2:][x::2] for x in (0, 1)])
5151
# save as attr-value dict, convert numbers into ints
5252
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))
5355
state = 3
5456
elif state == 3:
5557
# skip over parse tree
@@ -63,7 +65,7 @@ def parse_parser_results(text):
6365
split_entry = re.split("\(|, ", line[:-1])
6466
if len(split_entry) == 3:
6567
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]))
6769
print "\n", rel, left, right
6870
elif "Coreference links" in line:
6971
state = 5
@@ -104,13 +106,17 @@ def __init__(self):
104106

105107
print "Starting the Stanford Core NLP parser."
106108
# 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 ]
108112
pbar = ProgressBar(widgets=widgets, maxval=5, force_update=True).start()
109113
self._server.expect("done.", timeout=20) # Load pos tagger model (~5sec)
110114
pbar.update(1)
111115
self._server.expect("done.", timeout=200) # Load NER-all classifier (~33sec)
112116
pbar.update(2)
113117
self._server.expect("done.", timeout=600) # Load NER-muc classifier (~60sec)
118+
self.state = "Loading CoNLL classifier"
119+
widgets = ['Loading Models: ', Fraction(), ' ',
114120
pbar.update(3)
115121
self._server.expect("done.", timeout=600) # Load CoNLL classifier (~50sec)
116122
pbar.update(4)

0 commit comments

Comments
 (0)
0