LexiPy
LexiPy is a Python package that provides a simple lexer implementation. It allows you to tokenize a string by breaking it down into individual tokens. LexiPy also supports the usage of special terms, which can be treated as one token during tokenization, this can be usefull in domain specific cases like programming languages.
Installation
You can install LexiPy using pip:
pip install lexipy
Usage
Lexer Class (iterator)
The Lexer class returns an iterator over the tokens
from lexipy import Lexer
content = "Hello, World!"
lexer = Lexer(content, special_terms=None) # Iterator
tokens = list(lexer) # list of tokens list[str]
tokens
>>> ['hello', ',', 'world', '!']
content(str): The string to be tokenized.special_terms(set[str] | None, optional): A set of special terms to be treated as one token. Default isNone.
Returns an iterator over the tokens
lexify Function
The lexify function provides a more convenient way to tokenize a string.
from lexipy import lexify
content = "Hello, World!"
tokens = lexify(content, special_terms=None)
tokens
>>> ['hello', ',', 'world', '!']
content(str): The string to be tokenized.special_terms(set[str] | None, optional): A set of special terms to be treated as one token. Default isNone.
Returns a list of tokens.
Special terms
You can specify a set of special terms that should be treated as one token during the tokenization process. This can be useful when tokenizing programming languages or other cases where certain terms should not be split.
from lexipy import Lexer
content = "Hello, World!"
special_terms = {"world!"}
lexer = Lexer(content, special_terms=special_terms)
tokens = list(lexer)
tokens
>>> ['hello', ',', 'world!']
Note: The special terms are case insensitive
Planed features
- Adding an optional word stemmer (default: nltk), also support for custom stemmers through an interface
Contributing
Contributions to LexiPy are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.
License
LexiPy is licensed under the MIT License.
References
Metadata
Release files for lexipy 0.1.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 |
|---|---|---|---|---|
| lexipy-0.1.0.tar.gz | 2.8 kB | Without provenance | Details for lexipy-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lexipy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for lexipy-0.1.0-py3-none-any.whl |
Total release size: 6.1 kB
Release files / lexipy-0.1.0.tar.gz
| Download URL | lexipy-0.1.0.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
353f729e1f300a60d4924b1a1395531244d17ece2eb303259943f741a426c828
|
|
BLAKE2b-256 checksum How to use checksums |
a0416f205af7c38c99a6682e9769b8ee0301a8f7e234b667c1ea79587fcd5356
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.10.6 Windows/10
|
Release files / lexipy-0.1.0-py3-none-any.whl
| Download URL | lexipy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8cb33dc3348d165159cd18f5481b27bbce35dc4ae800424c11d2ad6c43eb0e5a
|
|
BLAKE2b-256 checksum How to use checksums |
195a701b567c025d8fcd99120bd93dac52035958b3c6e0230f404120e7e7ce3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.10.6 Windows/10
|
Security for lexipy 0.1.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.