news-navigator/code/code-merge-no-pretrained/4_create_sub_files.py

11 lines
448 B
Python
Raw Normal View History

2022-08-02 15:14:34 +02:00
# stworz format pliku wyjsciowego
for d in 'dev-0', 'test-A':
with open(f'../../{d}/in.tsv') as f_in, open(f'../../{d}/out.tsv','w') as f_out:
for line in f_in:
pred_path = f'predictions/{d}/labels/' + line.rstrip().replace('jpg','txt') + '-nonrelative'
try:
s = open(pred_path).read()
f_out.write(s + '\n')
except FileNotFoundError:
f_out.write('\n')