rossanez / KGen

Knowledge graphs generation from unstructured text.
Other
69 stars 27 forks source link

AssertionError: ERROR: Stanford CoreNLP Server exited with a non-zero code status. #4

Open davidshumway opened 2 years ago

davidshumway commented 2 years ago

Environment: macOS Monterey 12.1 (21C52)

$ python3 common/stanfordcorenlp/server.py

Starting Stanford CoreNLP Server from /Users/b/kgen/common/stanfordcorenlp
Stanford CoreNLP Server startup command: java -Djava.io.tmpdir="/tmp/" -mx5g -cp "/Users/b/kgen/common/stanfordcorenlp/stanford-corenlp.jar:/Users/b/kgen/common/stanfordcorenlp/stanford-corenlp-models.jar:/Users/b/kgen/common/stanfordcorenlp/slf4j-api.jar:/Users/b/kgen/common/stanfordcorenlp/slf4j-simple.jar:/Users/b/kgen/common/stanfordcorenlp/ejml.jar" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000
Error: Could not find or load main class edu.stanford.nlp.pipeline.StanfordCoreNLPServer
Caused by: java.lang.ClassNotFoundException: edu.stanford.nlp.pipeline.StanfordCoreNLPServer
Traceback (most recent call last):
  File "/Users/b/kgen/common/stanfordcorenlp/server.py", line 119, in <module>
    exit(main(argv))
  File "/Users/b/kgen/common/stanfordcorenlp/server.py", line 116, in main
    server.startServer(verbose=True, wait_for_subprocess=True)
  File "/Users/b/kgen/common/stanfordcorenlp/server.py", line 81, in startServer
    assert not java_process.returncode, 'ERROR: Stanford CoreNLP Server exited with a non-zero code status.'
AssertionError: ERROR: Stanford CoreNLP Server exited with a non-zero code status.
davidshumway commented 2 years ago

This appears to start the server, but then running preprocess doesn't appear to work.

PORT = 9000
BASE_URL = 'http://localhost'
URL = BASE_URL + ':{}'.format(PORT)
TIMEOUT = 15000
SHUTDOWN_URL = URL + '/shutdown'
TMPDIR_PROP = 'java.io.tmpdir'
TMPDIR = '/tmp/'
SHUTDOWN_KEY_FILE = TMPDIR + 'corenlp.shutdown'

jars = '{0}/stanford-corenlp.jar:{0}/stanford-corenlp-models.jar:{0}/slf4j-api.jar:{0}/slf4j-simple.jar:{0}/ejml.jar'\
.format('/Users/b/kgen/preprocessor')

command = 'java -D' + TMPDIR_PROP + '="' + TMPDIR + '" -mx5g' + \
  ' -cp "' + jars + '" edu.stanford.nlp.pipeline.StanfordCoreNLPServer' + \
  ' -port {} -timeout {}'.format(PORT, TIMEOUT)
from subprocess import Popen
from sys import stderr
java_process = Popen(command, stdout=1, shell=True)

Then:

$ ps -aux | grep java

root         394  0.0  0.0  34308  4780 ?        S    18:59   0:00 /bin/sh -c java -Djava.io.tmpdir="/tmp/" -mx5g -cp "/Users/b/kgen/preprocessor/stanford-corenlp.jar:/Users/b/kgen/preprocessor/stanford-corenlp-models.jar:/Users/b/kgen/preprocessor/slf4j-api.jar:/Users/b/kgen/preprocessor/slf4j-simple.jar:/Users/b/kgen/preprocessor/ejml.jar" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000
root         395  0.0  0.0  77204 13184 ?        Sl   18:59   0:00 java -Djava.io.tmpdir=/tmp/ -mx5g -cp /Users/b/kgen/preprocessor/stanford-corenlp.jar:/Users/b/kgen/preprocessor/stanford-corenlp-models.jar:/Users/b/kgen/preprocessor/slf4j-api.jar:/Users/b/kgen/preprocessor/slf4j-simple.jar:/Users/b/kgen/preprocessor/ejml.jar edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000
root         396  0.0  0.0  39196  6468 ?        S    18:59   0:00 /bin/bash -c ps -aux | grep java
root         398  0.0  0.0  38572  5648 ?        S    18:59   0:00 grep java

For example:

$ cd kgen/preprocessor
$ python3 preprocessor.py ../test.txt

Output appears to hang on coreferences step:

Processing text from /Users/b/kgen/test2txt
Resolving coreferences - please wait, as it may take a while ...
alanjguo commented 11 months ago

@davidshumway did you get it to work? also was planning to see the effectiveness of this approach.