请教如何在 pipeline 中添加 NE 模块?

print("Create pipeline tools: ")
tokenizer = hanlp.load('CTB6_CONVSEG')
tagger = hanlp.load(hanlp.pretrained.pos.CTB5_POS_RNN_FASTTEXT_ZH)
recognizer = hanlp.load(hanlp.pretrained.ner.MSRA_NER_BERT_BASE_ZH)
syntactic_parser = hanlp.load(hanlp.pretrained.dep.CTB7_BIAFFINE_DEP_ZH)

print("NE tokens:")
list_tokens = [list('上海华安工业(集团)公司董事长谭旭光和秘书张晚霞来到美国纽约现代艺术博物馆参观。'),
            list('萨哈夫说,伊拉克将同联合国销毁伊拉克大规模杀伤性武器特别委员会继续保持合作。')]

print(recognizer(list_tokens))

print("Build pipeline: ")
pipeline = hanlp.pipeline() \
    .append(hanlp.utils.rules.split_sentence, output_key='sentences') \
    .append(tokenizer, output_key='tokens') \
    .append(tagger, output_key='part_of_speech_tags') \
    .append(recognizer, input_key=list_tokens, output_key='ne_tags') \
    .append(syntactic_parser, input_key=('tokens', 'part_of_speech_tags'), output_key='syntactic_dependencies')

text = "HanLP是一系列模型与算法组成的自然语言处理工具包,目标是普及自然语言处理在生产环境中的应用。HanLP具备功能完善、性能高效、架构清晰、语料时新、可自定义的特点。内部算法经过工业界和学术界考验,配套书籍《自然语言处理入门》已经出版。"

print("Process text: ")
print(pipeline(text))

NE 的结果在 pipeline 中为空。recognizer 是需要提供一个 input_key 的参数吗?试了 tokens 和 part_of_speech_tags 都不行。

中文MSRA_NER_BERT_BASE_ZH并不依赖其他模块的输出,将其放入pipeline没有benefit。非要加的话,需要一个input_key,input_key的值必须是某个函数输出的list of chars。

明白了,主要是在一个 pipeline 中使用起来比较方便。所以你建议先把分句的结果,变为每个句子的 list, 然后单独处理 NE? 基本上还是要依赖分句吧?如果能支持一个统一的 pipeline 接口,感觉更好