From ed8ed03e5b39b3b13b0efc45130135034785f0a6 Mon Sep 17 00:00:00 2001 From: s45146 Date: Sat, 9 Dec 2017 18:18:34 +0100 Subject: [PATCH] =?UTF-8?q?Praca=20domowa=20nr=202=20(labs03)=20Rozwi?= =?UTF-8?q?=C4=85zanie=20-=20Piotr=20Bystrzycki=20-=20nr=20indeksu=2045146?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- labs03/task05.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/labs03/task05.py b/labs03/task05.py index 4eacdd5..190702e 100644 --- a/labs03/task05.py +++ b/labs03/task05.py @@ -9,8 +9,27 @@ Wyświetl tylko pełną nazwe pliku (wraz z ścieżką). """ +import glob + +def maxBleu(dir = './scores/', retmax = False): + maxbleu, fmax = None, None + for fn in glob.glob(dir+'model.iter*.npz.bleu'): + with open(fn, 'r') as f: + nmax = f.readline().replace(',', '').split(' ')[2] + if (maxbleu is None) or (float(maxbleu) < float(nmax)): + maxbleu = nmax + fmax = fn + else: + pass + if retmax: + retval = fmax+' : '+maxbleu + else: + retval = fmax + return retval + if __name__ == "__main__": - pass + #print(maxBleu(retmax = True)) + print(maxBleu())