Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8935743
commit 262a1f5
Showing
7 changed files
with
587 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
""" | ||
symbols | ||
""" | ||
import re | ||
|
||
# Resolve symbols and unescape any numeric character references | ||
def resolveSymbols(text): | ||
#h = html.parser.HTMLParser() | ||
|
||
textSplit = re.split("(&\#x?[0-9a-f]{2,6};)", text, flags=re.IGNORECASE) | ||
text2 = "" | ||
for t in textSplit: | ||
if t == "": | ||
text2 = text2 + t | ||
elif (t[0:2] == "&#") & (t[-1] == ";"): | ||
text2 = text2 + html.unescape(t) | ||
else: | ||
text2 = text2 + t | ||
|
||
# Replace certain entity references with actual characters | ||
text2 = text2.replace("=", "=") | ||
text2 = text2.replace("<", chr(236)) | ||
text2 = text2.replace(">", chr(237)) | ||
text2 = text2.replace("≤", "≤") | ||
text2 = text2.replace("≥", "≥") | ||
text2 = text2.replace("≈", "≈") | ||
text2 = text2.replace("Δ", "Δ") | ||
text2 = text2.replace("δ", "δ") | ||
text2 = text2.replace("∼", "∼") | ||
text2 = text2.replace(" ", chr(160)) | ||
text2 = text2.replace(";", ";") | ||
text2 = text2.replace(":", ":") | ||
text2 = text2.replace(",", ",") | ||
text2 = text2.replace("&", "&") | ||
text2 = text2.replace("←", "←") | ||
text2 = text2.replace("→", "→") | ||
text2 = text2.replace("↑", "↑") | ||
text2 = text2.replace("↓", "↓") | ||
text2 = text2.replace("↔", "↔") | ||
text2 = text2.replace("↕", "↕") | ||
text2 = text2.replace("↖", "↖") | ||
text2 = text2.replace("↗", "↗") | ||
text2 = text2.replace("↙", "↙") | ||
text2 = text2.replace("↘", "↘") | ||
text2 = text2.replace("[", "\[") | ||
text2 = text2.replace("]", "\]") | ||
text2 = text2.replace("∞", "∞") | ||
text2 = text2.replace("ä", "ä") | ||
text2 = text2.replace("Ä", "Ä") | ||
text2 = text2.replace("ü", "ü") | ||
text2 = text2.replace("Ü", "Ü") | ||
text2 = text2.replace("ö", "ö") | ||
text2 = text2.replace("Ö", "Ö") | ||
text2 = text2.replace("ß", "ß") | ||
text2 = text2.replace("€", "€") | ||
text2 = text2.replace("✓", "✓") | ||
text2 = text2.replace("…", "…") | ||
text2 = text2.replace("×", "×") | ||
text2 = text2.replace("%", "%") | ||
text2 = text2.replace("÷", "÷") | ||
text2 = text2.replace("∀", "∀") | ||
text2 = text2.replace("∃", "∃") | ||
text2 = text2.replace("λ", "λ") | ||
text2 = text2.replace("μ", "μ") | ||
text2 = text2.replace("ν", "ν") | ||
text2 = text2.replace("π", "π") | ||
text2 = text2.replace("ρ", "ρ") | ||
text2 = text2.replace("‐", "-") | ||
|
||
return text2 |
Oops, something went wrong.