From 1f74c9c019f227ea3ee414ec0fca40c9af892f9c Mon Sep 17 00:00:00 2001 From: Kento HASEGAWA Date: Tue, 28 Aug 2018 01:42:39 +0900 Subject: [PATCH] Fix typos and bugs --- comm/server/main.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/comm/server/main.py b/comm/server/main.py index f7e6ee2..24f267d 100644 --- a/comm/server/main.py +++ b/comm/server/main.py @@ -117,9 +117,8 @@ def update_answer_list(qname): if answer_log['solved'] == "True": is_solved = True - - if questions[qname]['answer'] == answer_log['answer']: - questions[qname]['best_json'] = json_name + if questions[qname]['answer'] == answer_log['answer']: + questions[qname]['best_json'] = json_name if (questions[qname]['last_req'] == float(answer_log['req_id'])): if answer_log['solver'] in questions[qname]['solver']: @@ -348,8 +347,12 @@ def save_best_solution(): _best_json = "" for k, v in questions[qname]['answers'].items(): - if v['nlcheck'] > _best_score: - _best_socer = v['nlcheck'] + try: + _score = float(v['nlcheck']) + except: + _score = -1 + if _score > _best_score: + _best_score = _score _best_json = k if _best_json != "": @@ -357,6 +360,8 @@ def save_best_solution(): if not os.path.isdir(out_path): os.makedirs(out_path) + print("Saved answer for {}: {}".format(qname, _best_json)) + qnumber = qname.replace("NL_Q", "").replace(".txt", "") out_file_path = "{}/T01_A{}.txt".format(out_path, qnumber) with open(out_file_path, 'w') as fp: -- 2.22.0