我是Java和Stanford NLP工具包的新手,并尝试将它们用于项目.具体来说,我正在尝试使用Stanford Corenlp工具包来注释文本(使用Netbeans而不是命令行),我尝试使用http://nlp.stanford.edu/software/corenlp.shtml#Usage上提供的代码(使用Stanford CoreNLP API)..问题是:有人能告诉我如何在文件中获取输出以便我可以进一步处理它吗?
我已经尝试将图形和句子打印到控制台,只是为了查看内容.这样可行.基本上我需要的是返回带注释的文档,这样我就可以从我的主类中调用它并输出一个文本文件(如果可能的话).我正在尝试查看stanford corenlp的API,但由于缺乏经验,我不知道返回此类信息的最佳方法是什么.
这是代码:
Properties props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
// read some text in the text variable
String text = "the quick fox jumps over the lazy dog";
// create an empty Annotation just with the given text
Annotation document = new Annotation(text);
// run all Annotators on this text
pipeline.annotate(document);
// these are all the sentences in this document
// …Run Code Online (Sandbox Code Playgroud)