単純な例を実行して、CoreNLPを開始するのはhereです。 coreNLPとモデル3.6をpom.xmlに追加しました。私もcom.google.protobuf(3.0.0-beta-3)をpomに追加しました。スタンフォードCoreNLPシンプルAPIエラー
私のコードがどのように見えるこの:
Document doc = new Document("add your text here! It can contain multiple sentences.");
for (Sentence sent : doc.sentences()) { // Will iterate over two sentences
// We're only asking for words -- no need to load any models yet
System.out.println("The second word of the sentence '" + sent + "' is " + sent.word(1));
// When we ask for the lemma, it will load and run the part of speech tagger
System.out.println("The third lemma of the sentence '" + sent + "' is " + sent.lemma(2));
// When we ask for the parse, it will load and run the parser
System.out.println("The parse of the sentence '" + sent + "' is " + sent.parse());
// ...
}
そして、ここでは例外です:
java.lang.NoSuchMethodError: edu.stanford.nlp.util.ArrayCoreMap.keySetNotNull()Ljava/util/Set; at edu.stanford.nlp.pipeline.ProtobufAnnotationSerializer.toProtoBuilder(ProtobufAnnotationSerializer.java:377) at edu.stanford.nlp.pipeline.ProtobufAnnotationSerializer.toProtoBuilder(ProtobufAnnotationSerializer.java:332) at edu.stanford.nlp.simple.Document.sentences(Document.java:480) at edu.stanford.nlp.simple.Document.sentences(Document.java:499)
UPDATE:
私はまだ同じ問題を2.6.1にいるProtobufを格下げして。ここで私のポンはどのように見える:
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.6.0</version>
<classifier>models</classifier>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.6.0</version>
</dependency>
</dependencies>
私は2.6.1でそれを試しましたが、それと同じエラー – webber
ローカルMavenキャッシュをクリアしてみてください。 –
あなたの例では "2.6.0"ではなく "2.6.1"と表示されています... 2.6.1を使用することも重要です。他のバージョンでは動作しないため、他のバージョンのprotobufを引っ張ってはいけません。 .. @ gabor btw私はこれを2.5年前に試してみましたが、失敗したと思いますので、2.6.1を使用して、それについて肯定的ではないと思っています。 – StanfordNLPHelp