[BUG]
sony-au opened this issue · 1 comments
This template is ONLY to be used for reporting bugs in the code.
ISSUE: Unable to connect to StanfordCoreNLPServer on Google Colab
Location
Current Behavior
unable to connect to StanfordCoreNLPServer
Expected Behavior
connected to StanfordCoreNLPServer
Possible Solution
can use Stanza, but give slightly different result (sentiment analysis on words, instead of sentence)
Steps to Reproduce
- download and install java:
import os
!apt-get install openjdk-8-jdk-headless -qq > /dev/null
os.environ["JAVA_HOME"] = "/usr/lib/jvm/java-8-openjdk-amd64" - download stanford-corenlp:
!wget "https://nlp.stanford.edu/software/stanford-corenlp-latest.zip"
!unzip "stanford-corenlp-latest.zip" - change directory:
cd stanford-corenlp-4.2.0/ - connect to server:
!java -mx5g -cp "./*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 10000
if using port 9000 (even though nothing else is using this port):
[main] INFO CoreNLP - --- StanfordCoreNLPServer#main() called ---
[main] INFO CoreNLP - Server default properties:
(Note: unspecified annotator properties are English defaults)
inputFormat = text
outputFormat = json
prettyPrint = false
[main] INFO CoreNLP - Threads: 2
[main] INFO CoreNLP - Starting server...
[main] WARN CoreNLP - java.net.BindException: Address already in use
java.base/sun.nio.ch.Net.bind0(Native Method)
java.base/sun.nio.ch.Net.bind(Net.java:455)
java.base/sun.nio.ch.Net.bind(Net.java:447)
java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80)
jdk.httpserver/sun.net.httpserver.ServerImpl.(ServerImpl.java:101)
jdk.httpserver/sun.net.httpserver.HttpServerImpl.(HttpServerImpl.java:50)
jdk.httpserver/sun.net.httpserver.DefaultHttpServerProvider.createHttpServer(DefaultHttpServerProvider.java:35)
jdk.httpserver/com.sun.net.httpserver.HttpServer.create(HttpServer.java:137)
edu.stanford.nlp.pipeline.StanfordCoreNLPServer.run(StanfordCoreNLPServer.java:1527)
edu.stanford.nlp.pipeline.StanfordCoreNLPServer.launchServer(StanfordCoreNLPServer.java:1624)
edu.stanford.nlp.pipeline.StanfordCoreNLPServer.main(StanfordCoreNLPServer.java:1631)
[Thread-0] INFO CoreNLP - CoreNLP Server is shutting down.
if using port 9001 (freeze at this point):
[main] INFO CoreNLP - --- StanfordCoreNLPServer#main() called ---
[main] INFO CoreNLP - Server default properties:
(Note: unspecified annotator properties are English defaults)
inputFormat = text
outputFormat = json
prettyPrint = false
[main] INFO CoreNLP - Threads: 2
[main] INFO CoreNLP - Starting server...
[main] INFO CoreNLP - StanfordCoreNLPServer listening at /0.0.0.0:9001
Context (Environment)
running the notebook on colab (on Windows 10)
python 3.6.9
pycorenlp-0.3.0
Please provide any more details you feel necessary
Possible Implementation
this is an option: https://colab.research.google.com/github/stanfordnlp/stanza/blob/master/demo/Stanza_CoreNLP_Interface.ipynb
duplicate