From fe683bed20b06d04db74a44b65c6dbd49d735b62 Mon Sep 17 00:00:00 2001 From: wangweiye7840 Date: Tue, 23 Jan 2024 11:50:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=96=B0=E9=A2=98=E6=AF=94?= =?UTF-8?q?=E5=AF=B9=E5=8A=9F=E8=83=BD=E5=B9=B6=E5=8A=A0=E5=85=A5=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/工具面板.py | 3 ++- 工具v2/新题比对.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 工具v2/新题比对.py diff --git a/工具v2/工具面板.py b/工具v2/工具面板.py index b74e404b..2ed489b5 100644 --- a/工具v2/工具面板.py +++ b/工具v2/工具面板.py @@ -69,7 +69,8 @@ ImportMenu.add_command(label = "寻找空闲题号", command = lambda: SetButton ImportMenu.add_separator() ImportMenu.add_command(label = "批量收录题目", command = lambda: SetButton("批量收录题目",["批量收录题目.py"])) ImportMenu.add_command(label = "添加关联题目", command = lambda: SetButton("添加关联题目",["添加关联题目.py"])) - +ImportMenu.add_separator() +ImportMenu.add_command(label = "新题比对", command = lambda: SetButton("新题比对",["新题比对.py"] )) # 设置 维护 菜单项 diff --git a/工具v2/新题比对.py b/工具v2/新题比对.py new file mode 100644 index 00000000..545bf02c --- /dev/null +++ b/工具v2/新题比对.py @@ -0,0 +1,37 @@ +outputpath = "临时文件/新题比对.tex" + + + +from database_tools import * +colors = ["green","orange","blue"] +templatepath = ".\模板文件\讲义模板.txt" + +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" +for p in problems: + p_treated = pre_treating(p) + output += f"\\item {p}\n\n" + t = stringmaxsim(p_treated,treated_dict,3) + count = 0 + for id,simrate in t: + output += "\\begin{tcolorbox}"+f"[colback = {colors[count]}!10!white, colframe = orange!10!white, breakable]\n" + output += f"{simrate:.3f} \\ {id}\n\n" + content = pro_dict[id]["content"] + output += f"{content}\n" + output += "\\end{tcolorbox}" + count += 1 + output += "\n\n" +output += "\n\\end{enumerate}\n\n" + +texraw = ReadTextFile(templatepath) +texdata = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",texraw,("新题比对"+f"{GetDate()}",output)) + + +texfilepath = os.path.join(os.getcwd(),outputpath) +SaveTextFile(texdata,texfilepath) +os.system(f"code {texfilepath}") +# dir,filename = os.path.split(texfilepath) +# XeLaTeXCompile(dir,filename) \ No newline at end of file