如何用法语设置 Stanford-NLP simple API?

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 (NC français)))(PUNC .)))

(ROOT(SENT(VN (CLS Il) (V contient))(NP (DET plusieurs) (NC phrases))(PUNC .)))

但实际输出是:

(ROOT (NP (NP (NNP Ceci) (NNP est)) (NP (NP (NN mon) (NN texte)) (PP (IN en) (NP (NN français)))) (. .))) (ROOT (NP (NP (NN Il)) (NP (JJ contient) (NNS plusieurs) (NNS phrases)) (. .)))

您是否尝试加载 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);