From f4e009d148214adaad9e2e5c0cf7432dee8f4030 Mon Sep 17 00:00:00 2001 From: "wagner.agnieszka" Date: Sun, 3 Jun 2018 00:23:55 +0200 Subject: [PATCH] passed --- labs04/labs04Task5.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 labs04/labs04Task5.py diff --git a/labs04/labs04Task5.py b/labs04/labs04Task5.py new file mode 100644 index 0000000..d77ed4a --- /dev/null +++ b/labs04/labs04Task5.py @@ -0,0 +1,21 @@ +import glob + +filelist = glob.glob('scores\\*.bleu') +bleu_filename = '' +max_bleu = 0 + + +def find_bleu(bleu_list, max_bleu): + for bleufile in bleu_list: + content = open(bleufile, 'r').read() + bleu = content.split(r',') + bleu_datum = bleu[0].split() + if max_bleu <= float(bleu_datum[2]): + max_bleu = float(bleu_datum[2]) + bleu_filename = bleufile + return bleu_filename, max_bleu + + +# filename, max_bleu = find_bleu([filelist[0]], max_bleu) +filename, max_bleu = find_bleu(filelist, max_bleu) +print(filename) \ No newline at end of file