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

11 lines
449 B
Python
Raw Normal View History

2022-08-02 12:09:06 +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 = 'predictions/dev-0/labels/' + line.rstrip().replace('jpg','txt') + '-nonrelative'
try:
s = open(pred_path).read()
f_out.write(s + '\n')
except FileNotFoundError:
f_out.write('\n')