我使用stanford CoreNLP工具特别是德国人选区解析器。 我在命令行工作。
这是我使用的命令:
java -cp "*" -Xmx2g edu.stanford.nlp.pipeline.StanfordCoreNLP -props StanfordCoreNLP-german.properties -annotators tokenize,ssplit,pos,parse -parse.model edu/stanford/nlp/models/srparser/germanSR.ser.gz -file Test.txt -outputFormat xml
然后我得到了以下内容:
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator tokenize
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator ssplit
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator pos
[main] INFO edu.stanford.nlp.tagger.maxent.MaxentTagger - Reading POS tagger model from edu/stanford/nlp/models/pos-tagger/german/german-hgc.tagger ... done [4.2 sec].
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator parse
[main] INFO edu.stanford.nlp.parser.common.ParserGrammar - Loading parser from serialized file edu/stanford/nlp/models/srparser/germanSR.ser.gz ... done [4.8 sec].
Processing file /home/students/park/Desktop/SWP/s_COREnlp_370/stanford-corenlp-full-2016-10-31/Test.txt ... writing to /home/students/park/Desktop/SWP/s_COREnlp_370/stanford-corenlp-full-2016-10-31/Test.txt.xml
Exception in thread "main" java.lang.NullPointerException
at edu.stanford.nlp.pipeline.ParserAnnotator.finishSentence(ParserAnnotator.java:309)
at edu.stanford.nlp.pipeline.ParserAnnotator.doOneSentence(ParserAnnotator.java:267)
at edu.stanford.nlp.pipeline.SentenceAnnotator.annotate(SentenceAnnotator.java:102)
at edu.stanford.nlp.pipeline.AnnotationPipeline.annotate(AnnotationPipeline.java:75)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.annotate(StanfordCoreNLP.java:605)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.annotate(StanfordCoreNLP.java:615)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.processFiles(StanfordCoreNLP.java:1167)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.processFiles(StanfordCoreNLP.java:948)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.run(StanfordCoreNLP.java:1256)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.main(StanfordCoreNLP.java:1326)
这个问题是什么原因造成的? 我该如何解决?
该命令适用于英语。
感谢您的帮助!
答案 0 :(得分:0)
确保您获得最新版本的Stanford CoreNLP 3.7.0。我认为这个bug已经修复,所以你应该再次下载它。当我使用最新代码运行样本句子时,没有NullPointer问题。