Adding new parser: MultiChoicesParser #133
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
I added a new parser called multi-choices parser. I couldn't find any efficient implementation of an incremental parser for this type of grammar in Python (even in packages specialized in grammar parsing) so I coded one myself here, which is presented in what follows.
Feature added: MultiChoicesParser (new parser)
Multi-choices Parser is an pure-Python efficient incremental parser for multi-choices grammars. These grammars are composed of lists of choices, where each choice is a literal string and can possibly be empty (grammar form below). This parser is optimized for scenarios where the size of the lists of choices is very large, such as representing entities preceded by a determiner (which is specifically my usecase).
Here is the type of grammar handled by this parser:
Example:
Implementation
I created a parser class named MultiChoicesParser which inherits from the CharacterLevelParser class and I implemented the abstract methods + cache_key method, which was intuitive and easy to follow.
I couldn't find where dependencies were handled for your package, is it possible to add this dependency https://github.com/HichemAK/multi-choices-parser to the project (through a "pip install multi-choices-parser" command)?
Tests
Best regards,
Hichem Ammar Khodja