About
A text parser written in the Python language.
The project has one goal, speed! See the benchmark below more details.
Project homepage: https://github.com/eerimoq/textparser
Documentation: http://textparser.readthedocs.org/en/latest
Credits
Thanks PyParsing for a user friendly interface. Many of textparser’s class names are taken from this project.
Installation
pip install textparser
Example usage
The Hello World example parses the string Hello, World! and outputs its parse tree ['Hello', ',', 'World', '!'].
The script:
import textparser
from textparser import Sequence
class Parser(textparser.Parser):
def token_specs(self):
return [
('SKIP', r'[ \r\n\t]+'),
('WORD', r'\w+'),
('EMARK', '!', r'!'),
('COMMA', ',', r','),
('MISMATCH', r'.')
]
def grammar(self):
return Sequence('WORD', ',', 'WORD', '!')
tree = Parser().parse('Hello, World!')
print('Tree:', tree)
Script execution:
$ env PYTHONPATH=. python3 examples/hello_world.py
Tree: ['Hello', ',', 'World', '!']
Benchmark
A benchmark comparing the speed of 10 JSON parsers, parsing a 276 kb file.
$ env PYTHONPATH=. python3 examples/benchmarks/json/speed.py
Parsed 'examples/benchmarks/json/data.json' 1 time(s) in:
PACKAGE SECONDS RATIO VERSION
textparser 0.10 100% 0.14.0
lark (LALR) 0.26 265% 0.6.2
funcparserlib 0.34 358% unknown
parsimonious 0.41 423% unknown
textx 0.53 548% 1.7.1
pyparsing 0.69 715% 2.2.0
pyleri 0.81 836% 1.2.2
parsy 0.94 976% 1.2.0
lark (Earley) 1.88 1949% 0.6.2
parsita 2.31 2401% unknown
$
NOTE 1: The parsers are not necessarily optimized for speed. Optimizing them will likely affect the measurements.
NOTE 2: The structure of the resulting parse trees varies and additional processing may be required to make them fit the user application.
NOTE 3: Only JSON parsers are compared. Parsing other languages may give vastly different results.
Contributing
Fork the repository.
Install prerequisites.
pip install -r requirements.txtImplement the new feature or bug fix.
Implement test case(s) to ensure that future changes do not break legacy.
Run the tests.
make testCreate a pull request.
Metadata
Release files for textparser 0.16.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| textparser-0.16.0.tar.gz | 11.1 kB | Without provenance | Details for textparser-0.16.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| textparser-0.16.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for textparser-0.16.0-py2.py3-none-any.whl |
Total release size: 20.4 kB
Release files / textparser-0.16.0.tar.gz
| Download URL | textparser-0.16.0.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e2d8b061b90679f6d4af47970f8a6fcdba173e6bc2a66e596b3a891a8a05ac95
|
|
BLAKE2b-256 checksum How to use checksums |
061fbd2b27915a4901e51d8b4dd475a980410283a3c1e0ef9264e3fe104a7625
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.9.1 pkginfo/1.4.1 requests/2.18.1 setuptools/38.5.0 requests-toolbelt/0.8.0 tqdm/4.14.0 CPython/2.7.12
|
Release files / textparser-0.16.0-py2.py3-none-any.whl
| Download URL | textparser-0.16.0-py2.py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
51d0efdadacd7a41031961ed4ddc6cb094ac96d22e236a6746462c6dd9dc7de9
|
|
BLAKE2b-256 checksum How to use checksums |
4ffd60915ef969476c4b7d54de3167d2a24c397af2ec205845a9bc9365956f41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.9.1 pkginfo/1.4.1 requests/2.18.1 setuptools/38.5.0 requests-toolbelt/0.8.0 tqdm/4.14.0 CPython/2.7.12
|
Security for textparser 0.16.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.