task05 done

This commit is contained in:
s45147 2017-12-09 23:17:38 +01:00
parent 984bf73c46
commit 5a79c51337

26
labs03/task05.py Normal file
View File

@ -0,0 +1,26 @@
#!/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)