{"id":6335,"library":"contractions","title":"Contractions","description":"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.","status":"active","version":"0.1.73","language":"en","source_language":"en","source_url":"https://github.com/kootenpv/contractions","tags":["NLP","text processing","text normalization","contractions","slang"],"install":[{"cmd":"pip install contractions","lang":"bash","label":"Install stable release"}],"dependencies":[],"imports":[{"symbol":"contractions","correct":"import contractions"},{"note":"The primary function is typically accessed via the imported module name.","wrong":"from contractions import fix; fix(\"text\")","symbol":"fix","correct":"contractions.fix(\"text\")"}],"quickstart":{"code":"import contractions\n\ntext = \"I'm happy now, and yall're doing great. We've gotta go!\"\nexpanded_text = contractions.fix(text)\nprint(f\"Original: {text}\")\nprint(f\"Expanded: {expanded_text}\")\n\n# You can also add custom contractions\ncontractions.add('mychange', 'my change')\ncustom_text = \"This is mychange.\"\nexpanded_custom_text = contractions.fix(custom_text)\nprint(f\"Custom: {expanded_custom_text}\")","lang":"python","description":"Expands common English contractions and slang in a given string. Demonstrates adding a custom contraction."},"warnings":[{"fix":"For critical applications requiring context-aware contraction expansion, consider alternative libraries (e.g., `pycontractions`) or implement custom rules to handle specific ambiguous cases.","message":"The library resolves ambiguous contractions (e.g., 'he's' could be 'he is' or 'he has') by defaulting to the most common expansion ('he is'). This might not always be contextually accurate. More advanced NLP libraries or forks like `pycontractions` or `sane-contractions` attempt to address this contextually.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"The PyPI metadata historically listed compatibility up to Python 3.6, which could be misleading. Users have confirmed successful operation with Python 3.8+ and up to 3.10+.","severity":"gotcha","affected_versions":"<=0.1.73"},{"fix":"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.","message":"There is a community-maintained fork, `sane-contractions`, which claims the original `contractions` library has been unmaintained since 2021 and offers active maintenance, performance improvements, and Python 3.10+ specific support.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Ensure you are using `contractions` version 0.0.18 or higher for optimal performance. The current version (0.1.73) already incorporates these improvements.","message":"Older versions of the library (prior to 0.0.18) were significantly slower. The official README strongly advises using versions greater than 0.0.18 for a 50x performance improvement.","severity":"gotcha","affected_versions":"<=0.0.18"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}