Python2017/labs03/task05.py
2017-12-09 23:17:38 +01:00

26 lines
613 B
Python

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import os
import glob
path = 'scores'
os.chdir(path)
max_file_name = ''
max_bleu = 0
file_list = glob.glob('model.iter[0-9][0-9][0-9][0-9][0-9].npz.bleu') + glob.glob('model.iter[0-9][0-9][0-9][0-9][0-9][0-9].npz.bleu')
for file in file_list:
with open(file, 'r') as f:
for line in f.readlines():
fc = line.find(',')
feq = line.find('=') + 1
bleu = float(line[feq:fc])
if bleu > max_bleu:
max_bleu = bleu
max_file_name = file
print(os.getcwd() + '\\' + max_file_name)