【发布时间】:2019-07-31 16:13:45
【问题描述】:
如何在 Spacy 中读取我的注释数据?
1) 我的注释数据的形式:
"annotation": [
[
79,
99,
"Nom complet"
],
2) 脚本中注释数据的形式:
"annotation": [
{
"label": [
"Companies worked at"
],
"points": [
{
"start": 1749,
"end": 1754,
"text": "Oracle"
}
]
},
3) 如何更改可以读取我的注释数据的代码?
for line in lines:
data = json.loads(line)
text = data['text']
entities = []
for annotation in data['annotation']:
#only a single point in text annotation.
point = annotation['points'][0]
labels = annotation['label']
# handle both list of labels or a single label.
if not isinstance(labels, list):
labels = [labels]
for label in labels:
dataturks indices are both inclusive [start, end] but spacy is not [start, end)
entities.append(([0], [1],[2]))
training_data.append((text, {"entities" : entities}))
【问题讨论】:
标签: python json python-3.x spacy entities