Open ghost opened 5 years ago
It was due to missing annotators which are required by the coref annotator. In fact running the equivalent in CoreNLP gives:
java -Xmx5g -cp stanford-corenlp-3.9.2.jar;stanford-corenlp-3.9.2-models.jar;* edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators coref -coref.algorithm neural -file example_file.txt
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator coref
[main] INFO edu.stanford.nlp.coref.neural.NeuralCorefAlgorithm - Loading coref model edu/stanford/nlp/models/coref/neural/english-model-default.ser.gz ... done [0.4 sec].
[main] INFO edu.stanford.nlp.coref.neural.NeuralCorefAlgorithm - Loading coref embeddings edu/stanford/nlp/models/coref/neural/english-embeddings.ser.gz ... done [0.4 sec].
[main] INFO edu.stanford.nlp.pipeline.CorefMentionAnnotator - Using mention detector type: rule
Exception in thread "main" java.lang.IllegalArgumentException: annotator "coref" requires annotation "BasicDependenciesAnnotation". The usual requirements for this annotator are: tokenize,ssplit,pos,lemma,ner,depparse
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:260)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:192)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:188)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.main(StanfordCoreNLP.java:1388)
but the error message is much more useful, as it directly tells you what is the problem and which annotators are missing. While the Python wrapper just gives a more obscure NullPointerException
I have the following MWE:
with the variable
CORENLP_HOME
properly defined. But the code crashes:If I use the statistical processor instead of the neural one, the code works as exepcted.