Convert Nemeth Braille math expressions into LaTeX.
This project provides:
- A Python translator (
Nemeth2LaTeXTranslator) - A CSV-based command-line workflow for batch conversion and validation
- Data-driven symbol/letter/number mapping tables
If you have Nemeth Braille strings (for example from a dataset or transcription process), this tool parses them and outputs LaTeX expressions.
The parser is built with lark, and token mappings are maintained in CSV files under nemeth/data/.
main.py: batch runner that reads an input CSV and writes conversion results to an output CSVnemeth/translator.py: high-level translator classnemeth/grammar.py: Lark grammar for Nemeth expressionsnemeth/transformer.py: parse-tree to LaTeX transformernemeth/data/*.csv: symbol, letter, and number mapping tablestestcase.csv,testcase2.csv: example datasetsunimathsymbols-data-merge/: helper scripts/data for symbol table preparation
- Python 3.8+
- Dependencies in
requirements.txt
Install dependencies:
pip install -r requirements.txtRun the provided testcase:
python main.py testcase.csv result.csvThis command:
- Reads each row from
testcase.csv - Converts
input-brailleto LaTeX - Compares the output with
expected-latex - Writes results to
result.csv
idinput-brailleexpected-latex
Example input row:
1,⠹⠆⠤⠂⠌⠒⠘⠆⠼,\frac{2-1}{3^2}idinput-brailleexpected-latexoutput-latexresult(True/False)
If parsing fails for a row, output-latex is written as parse error.
from nemeth.translator import Nemeth2LaTeXTranslator
translator = Nemeth2LaTeXTranslator()
latex = translator.translate("⠁⠘⠆") # a^2
print(latex)- Supported patterns are defined by the grammar and mappings in
nemeth/. - Ambiguous Nemeth symbols are resolved by mapping priority in the CSV tables.
- If your input includes unsupported patterns, translation may fail with a parse error.
- To add or adjust symbol behavior, edit files in
nemeth/data/. - If needed, use scripts in
unimathsymbols-data-merge/to help regenerate mapping data.