file1 = open(r'E:\数据\Conll2003_BMES\valid.txt', 'r', encoding='utf-8')
file2 = open(r'E:\数据\Conll2003_BIO\valid.txt', 'w+', encoding='utf-8')
str1=[]
for line in file1.readlines():
line1=line.split()
if len(line1)>1:
line2=list(line1[1])
if line2[0]=="M" or line2[0]=="E":
line2[0]="I"
elif line2[0]=="S":
line2[0]="B"
str2=''
for i in line2:
str2=str2+i
line=line1[0]+' '+str2
print(line)
str1.append(line)
for j in str1:
file2.write(j)
file2.write("\n")
NER数据集BMES格式转换为BIO格式
最新推荐文章于 2023-07-08 14:16:38 发布