小幅优化收录新题的方式
This commit is contained in:
parent
31fd47ac09
commit
c77cfc79af
|
|
@ -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"]
|
def generate_number_set(string,*thedict): #根据可能含有":"和","的题号字符串生成一个用逗号分隔的六位题号列表, 例如"1:3,5"会生成["000001","000002","000003","000005"]
|
||||||
#可变参数*dict如果存在, 将只生成dict的keys中包含的题号列表
|
#可变参数*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(",")
|
string_list = string.split(",")
|
||||||
numbers_list = []
|
numbers_list = []
|
||||||
for s in string_list:
|
for s in string_list:
|
||||||
|
|
|
||||||
13
工具v2/新题比对.py
13
工具v2/新题比对.py
|
|
@ -10,11 +10,20 @@ pro_dict = load_dict("../题库0.3/problems.json")
|
||||||
treated_dict = treat_dict(pro_dict)
|
treated_dict = treat_dict(pro_dict)
|
||||||
data = getCopy()
|
data = getCopy()
|
||||||
problems = [(d.strip()) for d in data.split("\\item") if not d.strip() == ""]
|
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:
|
for p in problems:
|
||||||
p_treated = pre_treating(p)
|
p_treated = pre_treating(p)
|
||||||
output += f"\\item {p}\n\n"
|
|
||||||
t = stringmaxsim(p_treated,treated_dict,3)
|
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
|
count = 0
|
||||||
for id,simrate in t:
|
for id,simrate in t:
|
||||||
output += "\n\\begin{tcolorbox}"+f"[colback = {colors[count]}!10!white, colframe = orange!10!white, breakable]\n"
|
output += "\n\\begin{tcolorbox}"+f"[colback = {colors[count]}!10!white, colframe = orange!10!white, breakable]\n"
|
||||||
|
|
|
||||||
Reference in New Issue