Yet Another Earley Parser: Efficient parsing algorithm for context-free grammars.
Project description
YAEP (Yet Another Earley Parser)
YAEP (Yet Another Earley Parser) is a high-performance package parsing syntax trees from Context-Free Grammars (CFGs). It implements the efficient Earley parsing algorithm, supporting ambiguity and generating comprehensive syntax trees. Designed for natural language processing (NLP) tasks, YAEP bridges theory and practice, providing computational linguists with a reliable tool for linguistic research and NLP applications.
Features
- Efficient parsing of CFGs
- Support for ambiguous and non-deterministic grammar
- Generation of comprehensive syntax trees
- Designed for NLP tasks and applications
Install dependency
pip install CairoSVG pydot
Getting Started
- Define your CFG grammar in json format.
- Utilize the YAEP API to parse sentences and generate syntax trees.
Examples
import YAEP
from YAEP import earley
from YAEP import utils
grammar = {
'S': [['VP'], ['NP']],
'VP': [['Verb']],
'NP': [['Det', 'Nominal'], ['Proper-Noun'], ['Noun']],
'Nominal': [['Noun'], ['Noun', 'Nominal']],
'Det': [['that'], ['this'], ['a']],
'Proper-Noun': [['Batman']],
'Noun': [['book'], ['flight'], ['banana'], ['meal'], ['factory']],
'Verb': [['book']],
}
words = "This book".split()
chart = earley.Earley().earley_parse(words, grammar)
parsed = [s for s in chart[-1] if s.left == 'S']
print(utils.tree_to_digraph(parsed[0],words))
Contributions and Feedback
Contributions and feedback are welcome! Please open an issue or submit a pull request on the YAEP GitHub repository for improvements, bug fixes, or suggestions.
License
YAEP is licensed under the MIT License. Feel free to use, modify, and distribute it according to the license terms.
Acknowledgments
YAEP builds upon the valuable contributions in computational linguistics and parsing algorithms. We express our gratitude to the researchers and developers who have influenced and inspired the development of YAEP.
Contact
For any inquiries or questions, please contact toandd.i81@gmail.com.
YAEP (Yet Another Earley Parser) is a high-performance package parsing syntax trees from Context-Free Grammars (CFGs). It provides efficient parsing, support for ambiguity, and comprehensive syntax tree generation for NLP tasks. Contributions and feedback are welcome. License: MIT. Contact: toandd.i81@gmail.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file PyParseEarley-1.0.1.tar.gz.
File metadata
- Download URL: PyParseEarley-1.0.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0b45c5a8d1fc606d25d8c3e14f939d131e9e599e1396bddea57bf1257e63496
|
|
| MD5 |
f31759222af7bd5a26ba4acf01729150
|
|
| BLAKE2b-256 |
077919ed6fc5eaca70a16d16adbf48156e8518560116f6d54299a5f7c5b3686d
|
File details
Details for the file PyParseEarley-1.0.1-py3-none-any.whl.
File metadata
- Download URL: PyParseEarley-1.0.1-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
289b9e6d7649357995dec4201797628a57d71b130813fe709979518f2c87aa19
|
|
| MD5 |
81129494869d9ad9329f436e84772075
|
|
| BLAKE2b-256 |
3ddbf088e91023753c4b9d6639724d5ac663e81f0bb93b9c68de269b1bf68208
|