如何在 Java 中为德语使用 Open NLP“NER”?

我正在尝试将 nlp 用于德语,但它不起作用! 我正在制作管道,然后 NER 来找到句子中每个元素的实体,这对于英语而不是 Geman 语言来说是完美的! 我还在 maven 中添加了德语... 这是我的管道:

public class Pipeline {
private static Properties properties;
private static String propertiesname = "tokenize,ssplit,pos,lemma,ner";
private static StanfordCoreNLP stanfordCoreNLP;

private Pipeline() {
}

static {
    properties = new Properties();
    properties.setProperty("annotators",propertiesname);
}

public static StanfordCoreNLP getPipeline(){
    if (stanfordCoreNLP == null){
        stanfordCoreNLP = new StanfordCoreNLP(properties);
    }
    return stanfordCoreNLP;
}

}

这是我的 NER:

public class NER {
public static void main(String[] args) {
    StanfordCoreNLP stanfordCoreNLP = Pipeline.getPipeline();
    String text = "hello My name is xxx. I live in Austria.";

    CoreDocument coreDocument = new CoreDocument(text);
    stanfordCoreNLP.annotate(coreDocument);

    List<CoreLabel> coreLabelList = coreDocument.tokens();

    for (CoreLabel coreLabel: coreLabelList){
        String ner = coreLabel.get(CoreAnnotations.NamedEntityTagAnnotation.class);
        System.out.println(coreLabel.originalText() + "->"+ner);
    }
}

}

这是我的 maven 依赖:

<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>4.0.0</version>
        <classifier>models-german</classifier>
    </dependency>

我应该更改或添加什么才能将其用于德语?

controlcls 回答:如何在 Java 中为德语使用 Open NLP“NER”?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/967874.html

大家都在问