From 033af3766aa31ba5fd2ab7ff08a824b1f7c88a2d Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Sat, 29 Jul 2023 11:21:18 +0800 Subject: [PATCH] =?UTF-8?q?mathpix=E8=AF=86=E5=88=AB=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=B8=AD=E6=96=B0=E5=A2=9E=E9=80=89=E6=8B=A9=E9=A2=98=E7=9A=84?= =?UTF-8?q?=E6=A8=AA=E7=BA=BF=E5=8F=98=E4=B8=BA=E6=8B=AC=E5=8F=B7=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/database_tools.py | 1 + 1 file changed, 1 insertion(+) diff --git a/工具v2/database_tools.py b/工具v2/database_tools.py index 02294ba6..578c90b2 100644 --- a/工具v2/database_tools.py +++ b/工具v2/database_tools.py @@ -1013,6 +1013,7 @@ def RefineMathpix(raw_string): # 进一步修改mathpix得到的字符串 string = re.sub(r"(是|为|(?:=\$))\s*([,.;\n])",lambda matchobj: matchobj.group(1) + "\\blank{50}" + ("." if matchobj.group(2) == "\n" else "") + matchobj.group(2),string) #给行中的题目需要的地方加上空格 string = re.sub(r"([\u4e00-\u9fa5\$])(?:\\bracket\{20\})*[\.]*[\s]*\n\\fourch",lambda matchobj: matchobj.group(1)+"\\bracket{20}.\n\\fourch",string) #给中文或公式结尾的题目最后一行加上选择题的括号. string = re.sub(r"(%[^\n]*)\\blank\{50\}\.",lambda matchobj:matchobj.group(1),string) #注释行不加\blank{50} + string = re.sub(r"\\blank\{50\}\.\s*\n\\fourch",r"\\bracket{20}."+"\n"+r"\\fourch",string) #选择题前的空格改为括号 string = re.sub(r"[\\\\]*\n(\(\d{1,2}\))(?:(?!\n)\s)*",lambda matchobj: "\\\\\n"+matchobj.group(1)+" ",string) #新一行的小题号回车前加上换行符 string = re.sub(r"\(([^\(\)]*(?:\\in|=|\\ge|\\le|\\ne|>|<|\\parallel|\\perp)[^\(\)]*)\)\$",lambda matchobj: "$($" + matchobj.group(1) + "$)",string) #公式最后的范围陈述的括号放到公式环境外 string = re.sub(r"\$\$\(","(",string) #删去上一步造成的多余双$