|
|
|
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') |
|
|
|
label_arr = line[0].split(' ') |
|
for i in range(len(label_arr)): |
|
count += 1 |
|
if label_arr[i] =="W": |
|
result.append(count) |
|
|
|
elif label_arr[i] =="O": |
|
|
|
a = 0 |
|
else: |
|
print("error word:",label_arr[i]) |
|
|
|
count += 1 |
|
|
|
|
|
print(count) |
|
o_f.write(str(result)) |
|
|
|
|