Java 在斯坦福核心NLP中使用管道
我在Eclipse中设置了一个Maven项目 它们的唯一类是src/main/java/App.java 包com.nlptools.corenlpJava 在斯坦福核心NLP中使用管道,java,stanford-nlp,Java,Stanford Nlp,我在Eclipse中设置了一个Maven项目 它们的唯一类是src/main/java/App.java 包com.nlptools.corenlp import java.util.List; import edu.stanford.nlp.pipeline.Annotation; import edu.stanford.nlp.sentiment.SentimentPipeline; import edu.stanford.nlp.pipeline.StanfordCoreNLP; cl
import java.util.List;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.sentiment.SentimentPipeline;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
class App
{
public static void main( String[] args )
{
List<Annotation> list = SentimentPipeline.getAnnotations(new StanfordCoreNLP(), null, "foo.txt", false);
for (Annotation item : list) {
System.out.println(item.toString());
}
System.out.println( "Hello World!" );
}
}
我正在查看文档,但无法理解:
我遗漏了什么?在Maven依赖项中,您需要这一点:
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.9.2</version>
<classifier>models</classifier>
</dependency>
管道变量是什么类型的?我如何初始化它?哎呀,我将把它添加进去。
Couldn't read TokensRegexNER from edu/stanford/nlp/models/kbp/english/gazetteers/regexner_caseless.tab
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.9.2</version>
<classifier>models</classifier>
</dependency>
Properties props = new Properties();
props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse,sentiment");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
CoreDocument exampleDocument = new CoreDocument("I loved the movie!");
pipeline.annotate(exampleDocument);
System.out.println(exampleDocument.sentences().get(0).sentiment());