Skip to content

Commit d550768

Browse files
committed
Merge pull request #4 from alvations/patch-1
Added a check for the server status
2 parents cfae0b2 + 20661d7 commit d550768

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pycorenlp/corenlp.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ def __init__(self, server_url):
1010
def annotate(self, text, properties=None):
1111
if not properties:
1212
properties = {}
13+
14+
# Checks that the Stanford CoreNLP server is started.
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')
21+
1322
r = requests.get(
1423
self.server_url, params={
1524
'properties': str(properties)

0 commit comments

Comments
 (0)