新增"多选题转为填空题"功能并加入功能面板

This commit is contained in:
weiye.wang 2024-02-12 13:59:57 +08:00
parent 85556de57e
commit 72e95a0c42
3 changed files with 30 additions and 0 deletions

View File

@ -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用.")

View File

@ -0,0 +1,12 @@
from database_tools import *
data = getCopy()
try:
output = MultiplechoicetoBlankFilling(data)
setCopy(output)
print("处理完成")
except:
print("处理失败")

View File

@ -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,[]))