{"id":4802,"library":"textstat","title":"Textstat","description":"Textstat is a Python library (version 0.7.13) for calculating a wide array of statistical features from text. It provides utilities for determining readability, complexity, and grade level using various metrics like Flesch Reading Ease, Gunning Fog, and SMOG Index. The library is actively maintained with regular patch releases addressing bug fixes and minor improvements.","status":"active","version":"0.7.13","language":"en","source_language":"en","source_url":"https://github.com/textstat/textstat","tags":["text analysis","readability","nlp","statistics","education"],"install":[{"cmd":"pip install textstat","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for 'en_US' syllable counting, specifically the 'cmudict' corpus.","package":"nltk","optional":true}],"imports":[{"note":"The 'Text' class is part of the 1.0.0-alpha pre-release API, not the stable 0.7.x series.","wrong":"from textstat import Text; Text('...').flesch_reading_ease()","symbol":"flesch_reading_ease","correct":"from textstat import flesch_reading_ease"},{"note":null,"wrong":null,"symbol":"text_standard","correct":"from textstat import text_standard"}],"quickstart":{"code":"import textstat\n\ntext = (\n    \"Playing games has always been thought to be important to \"\n    \"the development of well-balanced and creative children; \"\n    \"however, what part, if any, they should play in the lives \"\n    \"of adults has never been researched that deeply. I believe \"\n    \"that playing games is every bit as important for adults \"\n    \"as for children. Not only is taking time out to play games \"\n    \"with our children and other adults valuable to building \"\n    \"interpersonal relationships but is also a wonderful way \"\n    \"to release built up tension.\"\n)\n\n# Calculate Flesch Reading Ease score\nflesch_score = textstat.flesch_reading_ease(text)\nprint(f\"Flesch Reading Ease: {flesch_score}\")\n\n# Get the overall readability grade level\ngrade_level = textstat.text_standard(text)\nprint(f\"Readability Grade Level: {grade_level}\")\n\n# Syllable count (may require NLTK cmudict download for en_US)\nsyllable_count = textstat.syllable_count(text)\nprint(f\"Syllable Count: {syllable_count}\")\n\n# If NLTK cmudict is not downloaded for syllable_count:\n# import nltk\n# nltk.download('cmudict')","lang":"python","description":"This quickstart demonstrates how to use `textstat` to calculate the Flesch Reading Ease score, determine an approximate readability grade level, and count syllables in a given text. Note that for English (en_US) syllable counting, `nltk` and its 'cmudict' corpus might be required."},"warnings":[{"fix":"Ensure `nltk` is installed (`pip install nltk`) and download the 'cmudict' corpus if you encounter errors with `syllable_count` for English text: `import nltk; nltk.download('cmudict')`.","message":"The handling of the CMU Pronouncing Dictionary (`cmudict`) for syllable counting in 'en_US' has changed multiple times between versions 0.7.5 and 0.7.11. While version 0.7.13 defaults to `nltk.corpus.cmudict`, prior versions used `python-cmudict`. This can cause issues if `nltk` is not installed or the `cmudict` data is not downloaded.","severity":"breaking","affected_versions":"0.7.5 - 0.7.11"},{"fix":"Always refer to the documentation for your installed version. For stable 0.7.x, use direct function calls. If you intend to use the new object-oriented API, install the specific alpha release (e.g., `pip install textstat==1.0.0a1`).","message":"The `1.0.0-alpha` pre-releases introduce a completely new object-oriented API (e.g., `from textstat import Text`). This API is not compatible with the stable 0.7.x series, which uses direct functional imports (e.g., `from textstat import flesch_reading_ease`). Using the alpha API with a stable installation will result in `ImportError` or `AttributeError`.","severity":"gotcha","affected_versions":"0.7.x (stable) vs 1.0.0-alpha.x (pre-release)"},{"fix":"Be aware of the clamping behavior when comparing results with older versions. The change aims to provide more realistic grade level assessments.","message":"As of version 0.7.13, the `text_standard` function's grade levels are clamped to sensible bounds. This might result in different (potentially less extreme) grade level outputs compared to earlier versions that did not have this clamping.","severity":"gotcha","affected_versions":">=0.7.13"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}