我正在尝试将旧的 spacy 2.0 数据集转换为新的 spacy 3.0 可接受的格式,但我收到此错误“char_span() got an unexpected keyword argument 'alignment_mode'”错误,我应该如何解决这个错误?我正在使用此代码
import pandas as pd
from tqdm import tqdm
import spacy
from spacy.tokens import DocBin
nlp = spacy.blank("en") # load a new spacy model
db = DocBin() # create a DocBin object
for text, annot in tqdm(TRAIN_DATA): # data in previous format
doc = nlp.make_doc(text) # create doc object from text
ents = []
for start, end, label in annot["entities"]: # add character indexes
span = doc.char_span(start, end, label=label, alignment_mode="contract")
if span is None:
print("Skipping entity")
else:
ents.append(span)
doc.ents = ents # label the text with the ents
db.add(doc)
db.to_disk("./train.spacy") # save the docbin object
运行此脚本后,我收到此错误
TypeError: char_span() 得到了一个意外的关键字参数“alignment_mode”