![](/img/trans.png)
[英]how to use openie from stanford-corenlp without using lemma from stanford-corenlp?
[英]How can I use "NER" for German Language with stanford-corenlp?
我正在嘗試將 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>
我應該更改或添加什么以將其也用於德語?
我使用稍微不同的方法讓它工作,在我的 class 路徑中有stanford-corenlp-4.2.2.jar
和stanford-corenlp-4.2.1-models-german.jar
:
StanfordCoreNLP pipeline = new StanfordCoreNLP("german");
CoreDocument document = pipeline.processToCoreDocument(text);
基於此信息在其他人類語言上使用 CoreNLP 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.