The `contractions` library is a Python package (v0.1.73) designed for natural language processing (NLP) to expand English contractions and common slang terms into their full forms. It handles contractions like `you're` to `you are` and slang like `yall` to `you all`, aiming to standardize text for further analysis. It processes text by replacing shortened words and can also be extended with custom contraction rules. The library's last release was in November 2022, and it maintains a relatively stable release cadence.
pip install contractionsVerified import paths — ran on the pinned version, not inferred.
Expands common English contractions and slang in a given string. Demonstrates adding a custom contraction.
For critical applications requiring context-aware contraction expansion, consider alternative libraries (e.g., `pycontractions`) or implement custom rules to handle specific ambiguous cases.
The library generally works with recent Python 3 versions (3.8+). If you encounter issues, ensure you are using a version greater than 0.0.18 for performance improvements.
For new projects or if active maintenance, modern Python features, and guaranteed Python 3.10+ compatibility are crucial, consider evaluating `sane-contractions` instead. The original library had a release in late 2022, indicating some continued activity.
Ensure you are using `contractions` version 0.0.18 or higher for optimal performance. The current version (0.1.73) already incorporates these improvements.
Install the library using pip: `pip install contractions`
Instead of `from contractions import CONTRACTION_MAP`, use `from contractions import contractions_dict` to access the map, or simply use `contractions.fix()` for expansion without needing the map directly.
For basic usage, ensure you are using `contractions.fix(text)`. For complex or ambiguous contractions, review the output and consider using a more context-aware NLP library if the `contractions` library's default behavior is insufficient for your specific use case. The `pycontractions` library is an alternative that attempts to handle ambiguity using word embeddings and grammar checking.
No dependency data recorded yet.