From 5a79c513373c49e5f9811c80d3c32e23ee018723 Mon Sep 17 00:00:00 2001 From: s45147 Date: Sat, 9 Dec 2017 23:17:38 +0100 Subject: [PATCH] task05 done --- labs03/task05.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 labs03/task05.py 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