stanford-nlp - 如何在 core-nlp NER 中使用 IOB 类型的编码

标签 stanford-nlp named-entity-recognition

我正在尝试使用如下所示的训练集来训练我的 NER 模型。

British B-company 
Broadcasting    I-company 
Corporation I-company 
British nationality
public  B-orgTpye
service I-orgType
broadcaster I-orgTpye
headquartered   HQ
London  city
Newyork city
American    B-company
Airlines    I-company   
Jaguar  auto
Mercedes    auto
McLaren auto

当我运行 CRF 分类器时。它不识别 B 和 I。它将它们视为单独的 token 标签。

下面是我的分类器代码。

String[] String2StringArray =  "The British Broadcasting Corporation is a British public service broadcaster headquartered at Broadcasting House in London";   

    Properties props = new Properties();

            String basedir = ModelLocation");
            props.setProperty("ner.model", customModelFile"));
            props.setProperty("ner.model", basedir);
            props.setProperty("ner.combinationMode", "HIGH_RECALL");
            props.setProperty("ner.useSUTime", "true");
            Property("sutime.includeRange", "true");

            props.setProperty("ner.applyNumericClassifiers", "true");


    StringBuilder classifierOutputAsString = new StringBuilder();
            /*Combining different classifier models*/
            //NERClassifierCombiner classifierCombiner = new NERClassifierCombiner(props);
            NERClassifierCombiner classifierCombiner = new NERClassifierCombiner(true,true,GenericNERModel_A,customModelFile));


            for (String str : String2StringArray) {
                String classifiedToken = classifierCombiner.classifyWithInlineXML(str);
                classifierOutputAsString.append(classifiedToken);       

            }

        System.out.println(classifierOutputAsString.toString());

输出如下所示:

The <ORGANIZATION>British Broadcasting Corporation</ORGANIZATION> is a <nationality>British</nationality> <B-orgTpye>public</B-orgTpye> <I-orgType>service</I-orgType> <I-orgTpye>broadcaster</I-orgTpye> <HQ>headquartered</HQ> <city>at</city> <ORGANIZATION>Broadcasting House</ORGANIZATION> in <LOCATION>London</LOCATION>

最佳答案

基于之前对 SO 的回答作者:克里斯托弗·曼宁。我将这些行添加到 prop 文件中

    props.setProperty("entitySubclassification", "IOB1");
    props.setProperty("retainEntitySubclassification", "true");
    props.setProperty("mergeTags", "true");

现在,它使用 IOB 类型的编码。

关于stanford-nlp - 如何在 core-nlp NER 中使用 IOB 类型的编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44515297/

相关文章:

python - 斯坦福自然语言处理 : How to get chunks

java - CRFClassifier 无法识别句子分割器选项

java - JAVA 中字符串列表的机器学习分类,没有任何上下文围绕它们

stanford-nlp - 命名实体提取 - 用于货币

java - 调整 StanfordCoreNLP 来处理嘈杂的网络文本?

nlp - NER 语料库的带注释训练数据

nlp - 如何预测一个句子的概率?

python-3.x - 尝试加载 StanfordCoreNLP 时出现 psutil.AccessDenied 错误

regex - 具有正则表达式的命名实体识别: NLTK

testing - Weka:为什么用我的测试集重新评估没有给出任何结果而不抛出错误消息?