database_tools中添加全角标点转半角标点的功能RefinePuctuations
This commit is contained in:
parent
8508b45e59
commit
95d183593a
|
|
@ -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 "}
|
||||
|
|
|
|||
Reference in New Issue