修补database_tools中refind_mathpix函数识别选择题的一个bug

This commit is contained in:
weiye.wang 2024-01-04 22:27:31 +08:00
parent 8c781bd33b
commit be13308847
1 changed files with 1 additions and 1 deletions

View File

@ -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等