From c77cfc79af64d6e5f5edd5a6b0b6be464c256f75 Mon Sep 17 00:00:00 2001 From: wangweiye7840 Date: Thu, 1 Feb 2024 11:03:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E5=B9=85=E4=BC=98=E5=8C=96=E6=94=B6?= =?UTF-8?q?=E5=BD=95=E6=96=B0=E9=A2=98=E7=9A=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/database_tools.py | 4 +++- 工具v2/新题比对.py | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/工具v2/database_tools.py b/工具v2/database_tools.py index fbea09e1..9fa59252 100644 --- a/工具v2/database_tools.py +++ b/工具v2/database_tools.py @@ -128,7 +128,9 @@ def generate_problem_series(startingid,length,adict): #在adict字典里返回 def generate_number_set(string,*thedict): #根据可能含有":"和","的题号字符串生成一个用逗号分隔的六位题号列表, 例如"1:3,5"会生成["000001","000002","000003","000005"] #可变参数*dict如果存在, 将只生成dict的keys中包含的题号列表 - string = re.sub(r"[\n\s]","",string) + string = re.sub(r"[\n\s]","",string).strip() + while not string[-1] in "0123456789": + string = string[:-1] string_list = string.split(",") numbers_list = [] for s in string_list: diff --git a/工具v2/新题比对.py b/工具v2/新题比对.py index ee1ea8f3..98f35b26 100644 --- a/工具v2/新题比对.py +++ b/工具v2/新题比对.py @@ -10,11 +10,20 @@ pro_dict = load_dict("../题库0.3/problems.json") treated_dict = treat_dict(pro_dict) data = getCopy() problems = [(d.strip()) for d in data.split("\\item") if not d.strip() == ""] -output = "\\begin{enumerate}\n\n" +output = "使用说明: repxxxxxx表示使用已有题号xxxxxx, sxxxxxx,yyyyyy,...表示和xxxxxx,yyyyyy,...相同, rxxxxxx,yyyyyy,...表示和xxxxxx,yyyyyy,...相关\n\n\\begin{enumerate}\n\n" for p in problems: p_treated = pre_treating(p) - output += f"\\item {p}\n\n" t = stringmaxsim(p_treated,treated_dict,3) + psrstring = "" + for id,simrate in t: + if simrate == 1: + psrstring = "rep"+id + break + else: + psrstring += id + "," + if psrstring[-1] == ",": + psrstring = psrstring[:-1] + output += f"\\item [{psrstring}] {p}\n\n" count = 0 for id,simrate in t: output += "\n\\begin{tcolorbox}"+f"[colback = {colors[count]}!10!white, colframe = orange!10!white, breakable]\n"