stanfordcore NLP中的多个NER模型

时间:2018-05-03 14:05:27

标签: stanford-nlp ner

我试图检测一个句子是否有人名。我正在使用standford核心NLP java库

Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
props.setProperty("ner.model","edu/stanford/nlp/models/ner/chinese.misc.distsim.crf.ser.gz,edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz,edu/stanford/nlp/models/ner/german.conll.germeval2014.hgc_175m_600.crf.ser.gz,edu/stanford/nlp/models/ner/spanish.ancora.distsim.s512.crf.ser.gz");
standfordNERpipeline = new StanfordCoreNLP(props);
CoreDocument document = new CoreDocument(line.getText());
getStanfordPipeline.annotate(document);
CoreSentence sentence = document.sentences().get(0);
List<String> nerTags = sentence.nerTags();

由于我不知道这个人的种族,我想使用所有可用的NER模型。我在prop文件中使用了所有4个NER模型,用逗号分隔。但它似乎总是使用第一个模型(chineese)进行分类。

如何在一个句子中使用所有4个NER模型?

1 个答案:

答案 0 :(得分:0)

我不确定在英文文本上使用外语ner模型是一个好主意。

但是如果你将它添加到你的代码中它将解决你的问题:

props.setProperty("ner.combinationMode", "HIGH_RECALL")

这样,所有标签都允许输出所有4个模型。