my-model / countW.py
y-taki's picture
Upload 15 files
31ad59b
raw
history blame contribute delete
984 Bytes
#フゑむルを開く
import json
with open('/home2/y-taki/data3/research/M1/NER/transformers/examples/pytorch/token-classification/model/0807-5/ner/predictions.txt','r') as i_f:
with open('/home2/y-taki/data3/research/M1/NER/transformers/examples/pytorch/token-classification/model/0807-5/ner/pre-line.txt','w') as o_f:
count = 0
result = []
for line in i_f:
line = line.split('\n')
#print(line[1])
label_arr = line[0].split(' ')
for i in range(len(label_arr)):
count += 1
if label_arr[i] =="W":
result.append(count)
#print("W")
elif label_arr[i] =="O":
#print("O")
a = 0
else:
print("error word:",label_arr[i])
count += 1
#print("RESULT",result)
print(count)
o_f.write(str(result))