【发布时间】:2022-11-26 14:37:11
【问题描述】:
我有输入:
text = "Apple est une entreprise, James Alfred travaille ici"
spans = [
{
"start":0,
"end":5,
"label":"ORG"
},
{
"start":26,
"end":38,
"label":"PER"
}
]
correspondance_dict = {"PER":2, "ORG": 4 , "O" : 0}
我想标记文本并根据跨度列表构建标签,即:
我想要输出:
tokenized_text = ["Apple", "est", "une", "entreprise", "," , "James","Alfred", "travaille", "ici"]
labels = [4,0,0,0,0,2,2,0,0] #this list constructed with correspondance_dict and spans (4 because Apple is ORG and the "2,2" because "James,Alfred" is person
【问题讨论】:
标签: python python-3.x nlp spacy