Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoM-Matcher Optional Token Replacement Feature #211

Open
AndreG-P opened this issue Jan 29, 2021 · 1 comment
Open

PoM-Matcher Optional Token Replacement Feature #211

AndreG-P opened this issue Jan 29, 2021 · 1 comment
Assignees
Labels
Add-On New features Backlog Not important or urgent tasks Bug Bugs that need to be fixed Generic LaTeX Issues related to generic latex translations or discussions

Comments

@AndreG-P
Copy link
Member

Consider we want to replace the error function with the semantic macro. Currently, we have this:

\operatorname{erf}(z)

with the pattern that matches the expression:

\operatorname{erf}(var1)

Now, a semantic macro pattern may allow optional tokens in between (derivative or prime notation). For example, with the pattern we are unable to translate:

\operatorname{erf}^{(k)}(z)

The solution would be an optional token. Such as

\operatorname{erf} optToken (var1)

where optToken can be subscript or primes. Hence we can replace it by:

\erf optToken @@{var1}

where optToken can be empty.

This requires a lot of updates and is therefore out of scope. But something we should handle in the future.

@AndreG-P AndreG-P added Bug Bugs that need to be fixed Generic LaTeX Issues related to generic latex translations or discussions Backlog Not important or urgent tasks labels Jan 29, 2021
@AndreG-P AndreG-P self-assigned this Jan 29, 2021
@AndreG-P AndreG-P added the Add-On New features label Apr 27, 2021
@AndreG-P
Copy link
Member Author

As a first attempt to fix constraint-update issues, I implemented support to "skip" those optional tokens (primes and carets) but only after semantic macros. Hence, it does not fix this issue yet. It is also only activated when one uses

config.semanticMacroIgnoreTokenRule(true);

for the MatcherConfig.

If thats activated and such a token was skipped, it was captured and can be accessed via:
https://github.com/ag-gipp/LaCASt/blob/d9756a1bbfa4625bf4c79115c0111b662c060f01/interpreter.pom/src/main/java/gov/nist/drmf/interpreter/pom/extensions/GroupCaptures.java#L161-L187

To provide an example:

\EulerGamma@{var0}

would now match

\EulerGamma^{2}@{z}

with the following captured groups:

// returns a map with "var0" -> "z"
groupCaptured.getCapturedGroupStrings();

// returns a map with "optEulerGamma0" -> "^{2}"
groupCaptured.getOptionalSemanticCapturedGroupStrings()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Add-On New features Backlog Not important or urgent tasks Bug Bugs that need to be fixed Generic LaTeX Issues related to generic latex translations or discussions
Projects
None yet
Development

No branches or pull requests

1 participant