A Python library for working with weighted context-free grammars (WCFGs), weighted finite state automata (WFSAs) and weighted finite state transducers (WFSTs). The library provides efficient implementations for grammar operations, parsing algorithms, and language model functionality.
Quick Start
This library can be installed via pip:
pip install genlm-grammar
Key Features
Grammar Operations
- Support for weighted context-free grammars with various semirings (Boolean, Float, Real, MaxPlus, MaxTimes, etc.)
- Grammar transformations:
- Local normalization
- Removal of nullary rules and unary cycles
- Grammar binarization
- Length truncation
- Renaming/renumbering of nonterminals
Parsing Algorithms
- Earley parsing (O(n³|G|) complexity)
- Standard implementation
- Rescaled version for numerical stability
- CKY parsing
- Incremental CKY with chart caching
- Support for prefix computations
Language Model Interface
BoolCFGLM: Boolean-weighted CFG language modelCKYLM: Probabilistic CFG language model using CKYEarleyLM: Language model using Earley parsing
Finite State Automata
- Weighted FSA implementation
- Operations:
- Epsilon removal
- Minimization (Brzozowski's algorithm)
- Determinization
- Composition
- Reversal
- Kleene star/plus
Additional Features
- Semiring abstractions (Boolean, Float, Log, Entropy, etc.)
- Efficient chart and agenda-based algorithms
- Grammar-FST composition
- Visualization support via Graphviz
Development
See DEVELOPING.md for information on how to install the package in development mode.
Metadata
Release files for genlm-grammar 0.2.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 |
|---|---|---|---|---|
| genlm_grammar-0.2.0.tar.gz | 1.9 MB | Without provenance | Details for genlm_grammar-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| genlm_grammar-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for genlm_grammar-0.2.0-py3-none-any.whl |
Total release size: 2.0 MB
Release files / genlm_grammar-0.2.0.tar.gz
| Download URL | genlm_grammar-0.2.0.tar.gz |
|---|---|
| Size | 1.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b589fd7416c1068fc4c8eca5ccc5b63ea280bfd107ab8f5a1cb8af2846e94e14
|
|
BLAKE2b-256 checksum How to use checksums |
2a80cf0fa1578966848198d87c243b2ce2ad4898baf0fbd5a1960ba846e09afd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / genlm_grammar-0.2.0-py3-none-any.whl
| Download URL | genlm_grammar-0.2.0-py3-none-any.whl |
|---|---|
| Size | 53.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
393524396b454f7ef70d1f854111c62782689cd43abff2056b92463069925062
|
|
BLAKE2b-256 checksum How to use checksums |
02fbcf71d9e738396f16fb9e565cf72574c12e6e1ad5973a6fa5eb934a7dd00c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for genlm-grammar 0.2.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.