小幅优化收录新题的方式

This commit is contained in:
wangweiye7840 2024-02-01 11:03:39 +08:00
parent 31fd47ac09
commit c77cfc79af
2 changed files with 14 additions and 3 deletions

View File

@ -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:

View File

@ -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"