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"