[英]How to set Stanford-NLP simple API in french?
我试图在netbeans中使用法语中的stanford-nlp。 我正在使用netbeans 10.0和stanford-nlp 3.9.2。
我正在使用maven,我在我的pom中设置了这种依赖。
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.9.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.9.2</version>
<classifier>models</classifier>
</dependency>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.9.2</version>
<classifier>models-french</classifier>
</dependency
并且在java中有一个示例代码。
Document doc = new Document(props_fr,"Ceci est mon texte en français. Il contient plusieurs phrases.");
for (Sentence sent : doc.sentences()) {
System.out.println(sent.parse());
}
我希望输出(使用http://nlp.stanford.edu:8080/parser/ ):
(ROOT(SENT(NP(PRO Ceci))(VN(V est))(NP(DET mon)NC texte))(PP(P en)(NP(NCfrançais)))(PUNC。)))
(ROOT(SENT(VN(CLS Il)(V contient))(NP(DET plusieurs)(NC短语))(PUNC。)))
但实际输出是:
(RO(NP(NP(NNP Ceci)(NNP est))(NP(NP(NN mon)(NN texte))(PP(IN en)(NP(NNfrançais))))(。))))( ROOT(NP(NP(NN Il))(NP(JJ contient)(NNS plusieurs)(NNS短语))(。))))
您是否尝试加载StanfordCoreNLP-french.properties?
Properties props = new Properties();
props.load(IOUtils.readerFromString("StanfordCoreNLP-french.properties"));
StanfordCoreNLP corenlp = new StanfordCoreNLP(props);
Annotation ann = corenlp.process("Ceci est mon texte en français. Il contient plusieurs phrases.");
Document doc = new Document(props, ann);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.