file1 = open(r'E:\BMES_y\dev.txt', 'r', encoding='utf-8')
file2 = open(r'E:\BIOES_y\dev.txt', 'w+', encoding='utf-8')
str1=[]
'''
for line in file1.readlines():
#print(list(line))
if line!="\n":
line1 = line.split()
str2 = line1[0]
if len(line1) == 5:
for i in range(1, len(line1)):
line2 = list(line1[i])
if line2[0] == "M":
line2[0] = "I"
str3 = ''
for i in line2:
str3 = str3 + i
str2 = str2 + ' ' + str3
print(str2)
str1.append(str2)
else:
str1.append(line)
for j in str1:
file2.write(j)
file2.write("\n")
'''
for line in file1.readlines():
#print(list(line))
if line!="\n":
line1 = line.split()
str2 = line1[0]
for i in range(1, len(line1)):
line2 = list(line1[i])
if line2[0] == "M":
line2[0] = "I"
str3 = ''
for i in line2:
str3 = str3 + i
str2 = str2 + ' ' + str3
print(str2)
str1.append(str2)
else:
str1.append(line)
for j in str1:
file2.write(j)
file2.write("\n")
NER数据集BMES格式转换为BIOES格式
最新推荐文章于 2024-01-22 16:09:20 发布