news-navigator/code/code-merge-v6/4_create_sub_files.py
2022-08-02 13:18:36 +00:00

11 lines
448 B
Python

# 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')