HIT-SCIR / pyltp

pyltp: the python extension for LTP
1.53k stars 352 forks source link

pyltp命名实体识别,部分句子结果均为 O #219

Closed uniblackfire closed 4 years ago

uniblackfire commented 4 years ago

在提问之前,请确认以下几点:

问题类型

pyltp命名实体识别,部分句子结果均为 O

出错场景

异常句子:

操作系统的职能是管埋相控制计算机系统中的所有硬、软件资源,合理地组织计算机工作流程.并为用户提供个良好的工作环境和友好的接口。 ['O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O']

计算机系统的主要硬件资源有处理机、存储器.外存储器、输入/输出设备。 ['O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O']

正常句子:

美国国防部代理部长沙纳汉当地时间周一表示,已授权拨款10亿美元,用于总统特朗普修建部分美墨边境隔离墙。 ['S-Ns', 'O', 'O', 'B-Ns', 'E-Ns', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'S-Ns', 'O', 'O', 'O', 'O']

代码片段

    sents = list(SentenceSplitter.split(text))
    with open('./out.txt', encoding='utf-8', mode='w') as fd:
        for sent in sents:
            segmentor = Segmentor()
            segmentor.load(cws_model_path)
            words = segmentor.segment(sent)
            print(sent)
            fd.write('{}\n'.format(sent))
            if not len(words):
                continue
            words_list = list(words)
            postagger = Postagger()  # 初始化实例
            postagger.load(pos_model_path)  # 加载模型
            postags = postagger.postag(words)
            recognizer = NamedEntityRecognizer()
            recognizer.load(ner_model_path)
            netags = recognizer.recognize(words, postags)
            print(list(netags))

如何复现这一错误

运行环境

windows10, python 3.6.8

期望结果

正确识别'计算机系统'这样的命名实体

其他