From 72e95a0c420258c22deebd50134d74e3a3189f68 Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Mon, 12 Feb 2024 13:59:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E"=E5=A4=9A=E9=80=89=E9=A2=98?= =?UTF-8?q?=E8=BD=AC=E4=B8=BA=E5=A1=AB=E7=A9=BA=E9=A2=98"=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=B9=B6=E5=8A=A0=E5=85=A5=E5=8A=9F=E8=83=BD=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/database_tools.py | 17 +++++++++++++++++ 工具v2/多选题转为填空题.py | 12 ++++++++++++ 工具v2/工具面板.py | 1 + 3 files changed, 30 insertions(+) create mode 100644 工具v2/多选题转为填空题.py diff --git a/工具v2/database_tools.py b/工具v2/database_tools.py index 4e90cf1a..88ab7d99 100644 --- a/工具v2/database_tools.py +++ b/工具v2/database_tools.py @@ -1958,5 +1958,22 @@ def MaskingMathEnv(string_raw): #把string_raw中数学环境中的符号都转 string += "$" return string +def MultiplechoicetoBlankFilling(string_raw): #把多选题的题干和选项转为填空题 + firstchoicepos = re.search(r"(?:(?:four)|(?:two)|(?:one))ch",string_raw).span()[1] + headstring = string_raw[:firstchoicepos] + headstring = re.sub(r"\\bracket\{[\d]*\}",r"\\blank{50}",headstring) + headstring = re.sub(r"\n\\(?:(?:four)|(?:two)|(?:one))ch",r"\\\\\n",headstring) + string = string_raw[firstchoicepos:] + choices = [] + while "{" in string: + endpos = pairingbraces(string,0) + choices.append(string[1:endpos]) + string = string[endpos+1:] + output = "" + for i in range(len(choices)): + output += f"\\textcircled{{{i+1}}} {choices[i]}; " + output = headstring + output[:-2]+"." + return output + if __name__ == "__main__": print("数据库工具, import用.") \ No newline at end of file diff --git a/工具v2/多选题转为填空题.py b/工具v2/多选题转为填空题.py new file mode 100644 index 00000000..bdb6b163 --- /dev/null +++ b/工具v2/多选题转为填空题.py @@ -0,0 +1,12 @@ +from database_tools import * + + +data = getCopy() + +try: + output = MultiplechoicetoBlankFilling(data) + setCopy(output) + print("处理完成") +except: + print("处理失败") + diff --git a/工具v2/工具面板.py b/工具v2/工具面板.py index a9cc3be3..c91ef7f6 100644 --- a/工具v2/工具面板.py +++ b/工具v2/工具面板.py @@ -175,6 +175,7 @@ OtherMenu = Menu(menubar, tearoff = False) menubar.add_cascade(label = "其他", menu = OtherMenu) OtherMenu.add_command(label = "mathpix识别文本预处理", command = lambda: SetButton("mathpix识别文本预处理",[])) OtherMenu.add_command(label = "修改为带圈数字", command = lambda: SetButton("修改为带圈数字",[])) +OtherMenu.add_command(label = "多选题转为填空题", command = lambda: SetButton("多选题转为填空题",[])) OtherMenu.add_command(label = "剪贴板生成表格", command = lambda: SetButton("剪贴板生成表格",[])) # OtherMenu.add_command(label = "剪贴板带圈数字处理", command = lambda: SetButton("带圈数字处理",1,[])) # OtherMenu.add_command(label = "剪贴板表格整理", command = lambda: SetButton("剪贴板表格整理",1,[]))