diff --git a/labs03/task05.py b/labs03/task05.py new file mode 100644 index 0000000..a888f31 --- /dev/null +++ b/labs03/task05.py @@ -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) \ No newline at end of file