Skip to content

Commit 20661d7

Browse files
committed
Update corenlp.py
1 parent b0306ff commit 20661d7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pycorenlp/corenlp.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ def annotate(self, text, properties=None):
1212
properties = {}
1313

1414
# Checks that the Stanford CoreNLP server is started.
15-
assert requests.get(nlp.server_url).ok, \
16-
str('Check whether you have started the CoreNLP server, e.g. \n'
17-
'$ cd stanford-corenlp-full-2015-12-09/ \n'
18-
'$ java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer')
15+
try:
16+
requests.get(self.server_url).ok == True
17+
except requests.exceptions.ConnectionError:
18+
raise Exception('Check whether you have started the CoreNLP server e.g.\n'
19+
'$ cd stanford-corenlp-full-2015-12-09/ \n'
20+
'$ java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer')
1921

2022
r = requests.get(
2123
self.server_url, params={

0 commit comments

Comments
 (0)