'How can I use "NER" for German Language with stanford-corenlp?

I am trying to use nlp for german language but it does not work! I was making the pipeline and then NER to find the entity of each element in sentence which is working perfectly for English but not Geman language! I also added German language to maven... here is my pipeline:

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;
}

}

and here is my 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);
    }
}

}

and here is my maven 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>4.0.0</version>
        <classifier>models-german</classifier>
    </dependency>

what should I change or add to use it also for German Language?



Solution 1:[1]

I got it working using a slightly different approach, having stanford-corenlp-4.2.2.jar and stanford-corenlp-4.2.1-models-german.jar in my class path:

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

Based on this information Using CoreNLP on other human languages.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Konrad Holl