| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -2,7 +2,6 @@ | |
|
|
||
| certifi | ||
| coverage | ||
| pyparsing<3.0.0 | ||
| pytest!=4.6.0,!=5.4.0 | ||
| pytest-cov | ||
| pytest-rerunfailures | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCould this also have been fixed by changing oneOf(list(tex2uni)) to oneOf(list(tex2uni), asKeyword=True) and removing the FollowedBy altogether? This has the benefit of reducing the number of pyparsing terms to be matched, which should translate to faster parsing.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI think the problem of asKeyword is that "word boundary" needs a custom definition here (e.g. underscores and digits also separate words). I this this is configurable on pyparsing's side, but I'd rather just write our own regex (something like (?![a-zA-Z])) and be done with it.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis sounds like a better approach than trying to do custom keywords.
If you really want to collapse this down to a single Regex, then you could use oneOf to build a Regex for you of just the word choices, but then extract the generated regex pattern into a new Regex, something like Regex(r"\\(" + oneOf(text2uni).pattern + ")(?![a-zA-Z])"). (untested, ymmv, etc.)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualitytex symbols should not have any metacharacters, so the middle part is probably even just "|".join(tex2uni).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityBeware of this - oneOf also takes care of reordering longer entries before shorter in the event the shorter entry is a leading subset, and also deduping. You could just reverse sort the keys in tex2uni by length, but if there are known frequencies to some symbols vs others, and more frequent entries were placed first, oneOf would only reorder them to avoid masking entries, whereas sorting by longest-to-shortest would lose some of this priority ordering.
You can test this for yourself:
will return "ab", not the longer and more desirable match "abb". And there are several cases in tex2uni of these kind of masking pairs.
Maybe keep it simple first, just do "|".join(sorted(set(tex2uni), key=len, reverse=True)) and then get clever with the frequency-based ordering as a later experiment.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityAh, good point, thanks for mentioning that.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.