database_tools中添加全角标点转半角标点的功能RefinePuctuations

This commit is contained in:
weiye.wang 2024-03-03 13:56:29 +08:00
parent 8508b45e59
commit 95d183593a
1 changed files with 7 additions and 0 deletions

View File

@ -1385,6 +1385,13 @@ def itemizeProblems(string): #将题号替换为\item
string = "\n".join(itemed_list)
return string
def RefinePuctuations(raw_string):
puctuationsfulltosemi = {" ": " ","": ". ","": ". ","": ", ","": ": ","": "; ","": "(","": ")","": "? ","": "``","": "''", "": "[", "": "]"}
string = raw_string.strip()
for s in puctuationsfulltosemi:
string = re.sub(s,puctuationsfulltosemi[s],string) #将部分全角标记替换为半角
return string
def RefineMathpix(raw_string): # 进一步修改mathpix得到的字符串
puctuationsfulltosemi = {" ": " ","": ". ","": ". ","": ", ","": ": ","": "; ","": "(","": ")","": "? ","": "``","": "''", "": "[", "": "]"}
replacestrings = {r"\\overparen": r"\\overset\\frown", "eqslant": "eq", r"\\vec": r"\\overrightarrow ", r"\\bar": r"\\overline", r"\\lim": r"\\displaystyle\\lim", r"\\sum":r"\\displaystyle\\sum", r"\\prod":r"\\displaystyle\\prod", r"\\mid":"|", r"\^\{\\prime\}":"'",r"e\^":r"\\mathrm{e}^",r"/\s*/":r"\\parallel "}