From adb91f0d6bc904daacf4df64687fa9fcedb85313 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 15 Dec 2023 15:45:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=94=99=E8=AF=AF=E8=A1=A8=E8=BF=B0?= =?UTF-8?q?=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- start.py | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/start.py b/start.py index 73cce7b..73aa54b 100644 --- a/start.py +++ b/start.py @@ -49,38 +49,23 @@ def gen_doc(w1, w2): # w2 = json.loads(f.read()) # with open('w1.json', 'r', encoding='utf-8') as f: # w1 = json.loads(f.read()) - gdbs = 0 - yzbs = 0 - ybwz = 0 - zzcc = 0 + cate_dict = {} context = {'y': now.year, 'm': now.month, 'd': now.day, 'mo': now_3.month, 'do': now_3.day, 'su': 'xx', 'w1': w1, 'w2': w2} output_report_path = os.path.join(BASE_DIR, f'summary/{now.year}年{now.month}月-分析结果简报.docx') doc = DocxTemplate(TEMPLATE_REPORT_PATH) for i in w1: - if i[5] == '固定表述错误': - gdbs =gdbs + 1 - elif i[5] == '严重表述错误': - yzbs = yzbs +1 - elif i[5] == '一般文字差错': - ybwz = ybwz +1 - elif i[5] == '政治差错': - zzcc = zzcc +1 + if i[5] in cate_dict: + cate_dict[i[5]] = cate_dict[i[5]] + 1 else: - gdbs =gdbs + 1 + cate_dict[i[5]] = 1 for i in w2: - if i[5] == '固定表述错误': - gdbs =gdbs + 1 - elif i[5] == '严重表述错误': - yzbs = yzbs +1 - elif i[5] == '一般文字差错': - ybwz = ybwz +1 - elif i[5] == '政治差错': - zzcc = zzcc +1 + if i[5] in cate_dict: + cate_dict[i[5]] = cate_dict[i[5]] + 1 else: - gdbs =gdbs + 1 - - context['su'] = f'固定表述错误{gdbs}项, 严重表述错误{yzbs}项, 一般文字差错{ybwz}项, 政治差错{zzcc}项' - + cate_dict[i[5]] = 1 + context['su'] = '' + for k, v in cate_dict.items(): + context['su'] = context['su'] + f', {k}{v}项' doc.render(context) doc.save(output_report_path) return output_report_path