From be133088472931fe0e91a1a5feba5ff577b3105c Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Thu, 4 Jan 2024 22:27:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E8=A1=A5database=5Ftools=E4=B8=ADrefi?= =?UTF-8?q?nd=5Fmathpix=E5=87=BD=E6=95=B0=E8=AF=86=E5=88=AB=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E9=A2=98=E7=9A=84=E4=B8=80=E4=B8=AAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/database_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/工具v2/database_tools.py b/工具v2/database_tools.py index 15684024..6dd24f5a 100644 --- a/工具v2/database_tools.py +++ b/工具v2/database_tools.py @@ -1087,7 +1087,7 @@ def RefineMathpix(raw_string): # 进一步修改mathpix得到的字符串 string = re.sub(r"\$\s+\$"," ",string) #删除多余的$符号 string = re.sub(r"([,.:;?!])\$",lambda x:x.group(1)+" $",string) #标点和$符号分开 string = re.sub(r"\\frac",r"\\dfrac",string) #替换frac为dfrac - string = re.sub(r"\n(?:A\.|\(A\))([\s\S]*?)(?:B\.|\(B\))([\s\S]*?)(?:C\.|\(C\))([\s\S]*?)(?:D\.|\(D\))([\s\S]*?)\n",lambda matchobj: "\n\\fourch{%s}{%s}{%s}{%s}\n"%(matchobj.group(1).strip(),matchobj.group(2).strip(),matchobj.group(3).strip(),matchobj.group(4).strip()),string) # 选择题的选择支处理 + string = re.sub(r"\n(?:A\.|\(A\))([\s\S]*?)(?:B\.|\(B\))([\s\S]*?)(?:C\.|\(C\))([\s\S]*?)(?:D\.|\(D\))([\s\S]*?)\n",lambda matchobj: "\n\\fourch{%s}{%s}{%s}{%s}\n"%(matchobj.group(1).strip(),matchobj.group(2).strip(),matchobj.group(3).strip(),matchobj.group(4).strip()),string+"\n\n") # 选择题的选择支处理 string = re.sub(r"[\.;](\}\{|\}\n)",lambda matchobj: matchobj.group(1),string) #去除选择题选项最末尾的句号或分号 string = re.sub(r"\n\s+","\n",string) #删除多余的回车 string = re.sub(r"\\q+uad","",string) #删除\quad,\qquad等