gipplab / LaCASt

LaCASt - A LaTeX Translator for Computer Algebra Systems
MIT License
7 stars 1 forks source link

Replacement rules in config file #110

Closed AndreG-P closed 4 years ago

AndreG-P commented 4 years ago

Control replacement rules, such as ignore \displaystyle, via a separated config file.

HowardCohl commented 4 years ago

@AndreG-P

Where can I look to see the full collection of these replacement rules?

AndreG-P commented 4 years ago

@HowardCohl Currently they are hard-coded: https://github.com/ag-gipp/latex-grammar/blob/56c345546d153f7267bcf82e4dcdedc8b1e44cac/interpreter.common/src/main/java/gov/nist/drmf/interpreter/common/TeXPreProcessor.java#L15-L23

It just deletes displaystyle, hbox, all kind of \big, as well as \sb, \sf, ending white spaces, commas and periods. Also hiderel will be ignored, e.g., \hiderel{=} become just =. It also filters out spaces but only between digits, e.g., 23\;24 become 2324. Last but not least, I filter out line breaks.

Moritz thought it would be a good idea to define those rules in a separated file and I agree with him. In case we have to define rules like e->\expe as discussed in #109.

AndreG-P commented 4 years ago

Closed with https://github.com/ag-gipp/latex-grammar/commit/4c95617f98429b2e2b7b9dea5d19ef87c46c86a1 Replacement rules are organized in: https://github.com/ag-gipp/latex-grammar/blob/refactor-evaluation/config/dlmf-replacements.yml

and in: https://github.com/ag-gipp/latex-grammar/blob/refactor-evaluation/config/replacements.yml

Here is an example of the i to \iunit replacement rule: https://github.com/ag-gipp/latex-grammar/blob/4c95617f98429b2e2b7b9dea5d19ef87c46c86a1/config/dlmf-replacements.yml#L15-L18

The changes will be merged into master once the evaluation changes are done.