如何在斯坦福-科伦普中使用德语"NER"?



我正在尝试使用nlp德语,但它不工作!我正在制作管道,然后NER找到句子中每个元素的实体,这对英语来说是完美的,但对德语来说不是!我还为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>

我应该改变或添加什么,以使用它也为德国语言?

我使用稍微不同的方法使其工作,在我的类路径中有stanford-corenlp-4.2.2.jarstanford-corenlp-4.2.1-models-german.jar:

StanfordCoreNLP pipeline = new StanfordCoreNLP("german");
CoreDocument document = pipeline.processToCoreDocument(text);

基于此信息使用CoreNLP在其他人类语言

最新更新