我已经使用spacy 3.0培训了一个简单的NER管道。培训后,我想从aDoc
(doc = nlp(text)
)获得一个预测的IOB标签列表。例如,["O", "O", "B", "I", "O"]
我可以使用
>> doc.to_array("ENT_IOB")
array([2, 2, ..., 2], dtype=uint64)
但是我如何获得映射/查找
我在doc.vocab.lookups.tables
中没有找到任何查找表
我也知道,通过访问每个令牌([token.ent_iob_ for token in doc]
)上的ent_iob_
可以达到同样的效果,但我想知道是否有更好的方法
检查^{} 文档:
因此,您只需使用简单的
iob_map = {0: "", 1: "I", 2: "O", 3: "B"}
字典替换将ID映射到名称:相关问题 更多 >
编程相关推荐