Search code examples
pythonpython-3.xstanford-nlppython-3.6corenlp-server

Connect to Dedicated Server - CoreNLP


I am looking for the python code required to connect to a local instantiation of the Stanford CoreNLP Server.

I have successfully connected and communicated with Stanford's server where you need to enter the following into the command line prompt:

java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000

and have nlp = StanfordCoreNLP('http://localhost:9000') in your python code.

I now have a local CoreNLP server operating on CentOS 6. I use the terminal prompt: sudo service corenlp start and get the system response CoreNLP server started. Which I assume means my local instantiation of the CoreNLP server is listening for any requests. I now need to know how to communicate with my local server.

Can anyone enlighten me on what I need to replace nlp = StanfordCoreNLP('http://localhost:9000') with in order to be able to talk to my local CoreNLP Server?


Solution

  • You should use the Stanford NLP group's Python library stanza:

    https://github.com/stanfordnlp/stanza

    Hopefully over the next month there will be better documentation and support for starting and stopping the server in Python.