Download scripts/_probe.py from m-rui001/physics-typst-corpus: direct link, hf CLI and curl.
- Browser
- Download file 691 Bytes
-
https://huggingface.co/datasets/m-rui001/physics-typst-corpus/resolve/main/scripts/_probe.py
- Command line
-
hf download hf://datasets/m-rui001/physics-typst-corpus/scripts/_probe.py
-
curl -L -o _probe.py https://huggingface.co/datasets/m-rui001/physics-typst-corpus/resolve/main/scripts/_probe.py
691 Bytes
| import sys, re | |
| sys.path.insert(0, 'scripts') | |
| import escmath2 as E, resplice | |
| s = open('papers/2308.08546/main.typ', encoding='utf-8').read() | |
| i = s.find('begin{equation}') | |
| a = s.rfind(E.B + '$' + E.B + '$', 0, i) | |
| b = s.find(E.B + '$' + E.B + '$', i) | |
| raw = E.unesc(s[a + 4:b]) | |
| raw = E.ENV.sub(r"\\begin{aligned}", raw) | |
| raw = E.ENVEND.sub(r"\\end{aligned}", raw) | |
| raw = re.sub(r"\\label\{[^}]*\}", "", raw) | |
| raw = re.sub(r'\{"([^{}"]*)"\}', r"\\text{\1}", raw) | |
| raw = re.sub(r'"([^"{}]*)"', r"\\text{\1}", raw) | |
| raw = raw.replace("\\*", "*") | |
| print('STAGE', repr(raw[:260])) | |
| out, err = resplice._conv('$' + raw + '$', 'papers/2308.08546/_work') | |
| print('ERR', err[:700]) | |
| print('OUT', repr(out[:200])) | |