{"id":13678781,"url":"https://github.com/textstat/textstat","last_synced_at":"2026-02-18T23:00:51.856Z","repository":{"id":17966113,"uuid":"20958957","full_name":"textstat/textstat","owner":"textstat","description":":memo: python package to calculate readability statistics of a text object - paragraphs, sentences, articles.","archived":false,"fork":false,"pushed_at":"2025-12-22T10:28:14.000Z","size":1524,"stargazers_count":1349,"open_issues_count":20,"forks_count":185,"subscribers_count":18,"default_branch":"main","last_synced_at":"2026-02-18T10:43:09.086Z","etag":null,"topics":["flesch-kincaid-grade","flesch-reading-ease","python","readability","smog","textstat"],"latest_commit_sha":null,"homepage":"https://textstat.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/textstat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2014-06-18T10:54:08.000Z","updated_at":"2026-02-17T16:34:56.000Z","dependencies_parsed_at":"2022-07-12T05:15:05.980Z","dependency_job_id":"94cb8ab2-94e7-4bbe-afd0-073d1a4163c0","html_url":"https://github.com/textstat/textstat","commit_stats":{"total_commits":306,"total_committers":48,"mean_commits":6.375,"dds":0.6437908496732025,"last_synced_commit":"bc125f6f6657bdd2ff3c89e22682808aa6ebef2a"},"previous_names":["shivam5992/textstat"],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/textstat/textstat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textstat%2Ftextstat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textstat%2Ftextstat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textstat%2Ftextstat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textstat%2Ftextstat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/textstat","download_url":"https://codeload.github.com/textstat/textstat/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textstat%2Ftextstat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29597853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T22:25:43.180Z","status":"ssl_error","status_checked_at":"2026-02-18T22:25:42.766Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flesch-kincaid-grade","flesch-reading-ease","python","readability","smog","textstat"],"created_at":"2024-08-02T13:00:58.234Z","updated_at":"2026-02-18T23:00:51.850Z","avatar_url":"https://github.com/textstat.png","language":"Python","readme":"# Textstat\n\n[![PyPI](https://img.shields.io/pypi/v/textstat.svg)](https://pypi.org/project/textstat/)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/textstat/textstat/test.yml?branch=main\u0026label=main\u0026logo=github\u0026logoColor=white)](https://github.com/textstat/textstat/actions/workflows/test.yml)\n[![Downloads](https://img.shields.io/pypi/dm/textstat?logo=pypi\u0026logoColor=white)](https://pypistats.org/packages/textstat)\n\n**Textstat is an easy to use library to calculate statistics from text. It helps determine readability, complexity, and grade level.**\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"100%\" src=\"https://images.unsplash.com/photo-1457369804613-52c61a468e7d?ixlib=rb-1.2.1\u0026auto=format\u0026fit=crop\u0026w=1350\u0026h=400\u0026q=80\"\u003e\n\u003c/p\u003e\n\u003cp align=\"right\"\u003e\n  \u003csup\u003ePhoto by \u003ca href=\"https://unsplash.com/@impatrickt\"\u003ePatrick Tomasso\u003c/a\u003e\n  on \u003ca href=\"https://unsplash.com/images/things/book\"\u003eUnsplash\u003c/a\u003e\u003c/sup\u003e\n\u003c/p\u003e\n\n## Usage\n\n```python\n\u003e\u003e\u003e import textstat\n\n\u003e\u003e\u003e test_data = (\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\u003e\u003e\u003e textstat.flesch_reading_ease(test_data)\n\u003e\u003e\u003e textstat.flesch_kincaid_grade(test_data)\n\u003e\u003e\u003e textstat.smog_index(test_data)\n\u003e\u003e\u003e textstat.coleman_liau_index(test_data)\n\u003e\u003e\u003e textstat.automated_readability_index(test_data)\n\u003e\u003e\u003e textstat.dale_chall_readability_score(test_data)\n\u003e\u003e\u003e textstat.difficult_words(test_data)\n\u003e\u003e\u003e textstat.linsear_write_formula(test_data)\n\u003e\u003e\u003e textstat.gunning_fog(test_data)\n\u003e\u003e\u003e textstat.text_standard(test_data)\n\u003e\u003e\u003e textstat.fernandez_huerta(test_data)\n\u003e\u003e\u003e textstat.szigriszt_pazos(test_data)\n\u003e\u003e\u003e textstat.gutierrez_polini(test_data)\n\u003e\u003e\u003e textstat.crawford(test_data)\n\u003e\u003e\u003e textstat.gulpease_index(test_data)\n\u003e\u003e\u003e textstat.osman(test_data)\n```\n\nThe argument (text) for all the defined functions remains the same -\ni.e the text for which statistics need to be calculated.\n\n## Install\n\nYou can install textstat either via the Python Package Index (PyPI) or from source.\n\n### Install using pip\n\n```shell\npip install textstat\n```\n\n### Install using easy_install\n\n```shell\neasy_install textstat\n```\n\n### Install latest version from GitHub\n\n```shell\ngit clone https://github.com/textstat/textstat.git\ncd textstat\npip install .\n```\n\n### Install from PyPI\n\nDownload the latest version of textstat from http://pypi.python.org/pypi/textstat/\n\nYou can install it by doing the following:\n\n```shell\ntar xfz textstat-*.tar.gz\ncd textstat-*/\npython setup.py build\npython setup.py install # as root\n```\n\n## Language support\nBy default functions implement algorithms for english language. \nTo change language, use:\n\n```python\ntextstat.set_lang(lang)\n``` \n\nThe language will be used for syllable calculation and to choose \nvariant of the formula.\n\n### Language variants\nAll functions implement `en_US` language. Some of them has also variants \nfor other languages listed below. \n\n|  Function                   | en | de | es | fr | it | nl | pl | ru |\n|-----------------------------|----|----|----|----|----|----|----|----|\n| flesch_reading_ease         | ✔  | ✔  | ✔  | ✔  | ✔  | ✔  |    | ✔  |\n| gunning_fog                 | ✔  |    |    |    |    |    | ✔  |    |\n\n#### Spanish-specific tests\nThe following functions are specifically designed for spanish language.\nThey can be used on non-spanish texts, even though that use case is not recommended.\n\n```python\n\u003e\u003e\u003e textstat.fernandez_huerta(test_data)\n\u003e\u003e\u003e textstat.szigriszt_pazos(test_data)\n\u003e\u003e\u003e textstat.gutierrez_polini(test_data)\n\u003e\u003e\u003e textstat.crawford(test_data)\n```\n\nAdditional information on the formula they implement can be found in their respective docstrings.\n\n## List of Functions\n\n### Formulas\n\n#### The Flesch Reading Ease formula\n\n```python\ntextstat.flesch_reading_ease(text)\n```\n\nReturns the Flesch Reading Ease Score.\n\nThe following table can be helpful to assess the ease of\nreadability in a document.\n\nThe table is an _example_ of values. While the\nmaximum score is 121.22, there is no limit on how low\nthe score can be. A negative score is valid.\n\n| Score |    Difficulty     |\n|-------|-------------------|\n|90-100 | Very Easy         |\n| 80-89 | Easy              |\n| 70-79 | Fairly Easy       |\n| 60-69 | Standard          |\n| 50-59 | Fairly Difficult  |\n| 30-49 | Difficult         |\n| 0-29  | Very Confusing    |\n\n\u003e Further reading on\n[Wikipedia](https://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests#Flesch_reading_ease)\n\n#### The Flesch-Kincaid Grade Level\n\n```python\ntextstat.flesch_kincaid_grade(text)\n```\n\nReturns the Flesch-Kincaid Grade of the given text. This is a grade\nformula in that a score of 9.3 means that a ninth grader would be able to\nread the document.\n\n\u003e Further reading on\n[Wikipedia](https://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests#Flesch%E2%80%93Kincaid_grade_level)\n\n#### The Fog Scale (Gunning FOG Formula)\n\n```python\ntextstat.gunning_fog(text)\n```\n\nReturns the FOG index of the given text. This is a grade formula in that\na score of 9.3 means that a ninth grader would be able to read the document.\n\n\u003e Further reading on\n[Wikipedia](https://en.wikipedia.org/wiki/Gunning_fog_index)\n\n#### The SMOG Index\n\n```python\ntextstat.smog_index(text)\n```\n\nReturns the SMOG index of the given text. This is a grade formula in that\na score of 9.3 means that a ninth grader would be able to read the document.\n\nTexts of fewer than 30 sentences are statistically invalid, because\nthe SMOG formula was normed on 30-sentence samples. textstat requires at\nleast 3 sentences for a result.\n\n\u003e Further reading on\n[Wikipedia](https://en.wikipedia.org/wiki/SMOG)\n\n#### Automated Readability Index\n\n```python\ntextstat.automated_readability_index(text)\n```\n\nReturns the ARI (Automated Readability Index) which outputs\na number that approximates the grade level needed to\ncomprehend the text.\n\nFor example if the ARI is 6.5, then the grade level to comprehend\nthe text is 6th to 7th grade.\n\n\u003e Further reading on\n[Wikipedia](https://en.wikipedia.org/wiki/Automated_readability_index)\n\n#### The Coleman-Liau Index\n\n```python\ntextstat.coleman_liau_index(text)\n```\n\nReturns the grade level of the text using the Coleman-Liau Formula. This is\na grade formula in that a score of 9.3 means that a ninth grader would be\nable to read the document.\n\n\u003e Further reading on\n[Wikipedia](https://en.wikipedia.org/wiki/Coleman%E2%80%93Liau_index)\n\n#### Linsear Write Formula\n\n```python\ntextstat.linsear_write_formula(text)\n```\n\nReturns the grade level using the Linsear Write Formula. This is\na grade formula in that a score of 9.3 means that a ninth grader would be\nable to read the document.\n\n\u003e Further reading on\n[Wikipedia](https://en.wikipedia.org/wiki/Linsear_Write)\n\n#### Dale-Chall Readability Score\n\n```python\ntextstat.dale_chall_readability_score(text)\n```\n\nDifferent from other tests, since it uses a lookup table\nof the most commonly used 3000 English words. Thus it returns\nthe grade level using the New Dale-Chall Formula.\n\n| Score       |  Understood by                                |\n|-------------|-----------------------------------------------|\n|4.9 or lower | average 4th-grade student or lower            |\n|  5.0–5.9    | average 5th or 6th-grade student              |\n|  6.0–6.9    | average 7th or 8th-grade student              |\n|  7.0–7.9    | average 9th or 10th-grade student             |\n|  8.0–8.9    | average 11th or 12th-grade student            |\n|  9.0–9.9    | average 13th to 15th-grade (college) student  |\n\n\u003e Further reading on\n[Wikipedia](https://en.wikipedia.org/wiki/Dale%E2%80%93Chall_readability_formula)\n\n#### Readability Consensus based upon all the above tests\n\n```python\ntextstat.text_standard(text, float_output=False)\n```\n\nBased upon all the above tests, returns the estimated school\ngrade level required to understand the text.\n\nOptional `float_output` allows the score to be returned as a\n`float`. Defaults to `False`.\n\n#### Spache Readability Formula\n\n```python\ntextstat.spache_readability(text)\n```\n\nReturns grade level of english text.\n\nIntended for text written for children up to grade four.\n\n\u003e Further reading on\n[Wikipedia](https://en.wikipedia.org/wiki/Spache_readability_formula)\n\n#### McAlpine EFLAW Readability Score\n\n```python\ntextstat.mcalpine_eflaw(text)\n```\n\nReturns a score for the readability of an english text for a foreign learner or\nEnglish, focusing on the number of miniwords and length of sentences.\n\nIt is recommended to aim for a score equal to or lower than 25. \n\n\u003e Further reading on\n[This blog post](https://strainindex.wordpress.com/2009/04/30/mcalpine-eflaw-readability-score/)\n\n#### Reading Time\n\n```python\ntextstat.reading_time(text, ms_per_char=14.69)\n```\n\nReturns the reading time of the given text.\n\nAssumes 14.69ms per character.\n\n\u003e Further reading in\n[This academic paper](https://homepages.inf.ed.ac.uk/keller/papers/cognition08a.pdf)\n\n### Language Specific Formulas \n#### Índice de lecturabilidad Fernandez-Huerta (Spanish)  \n\n```python\ntextstat.fernandez_huerta(text)\n```\n\nReformulation of the Flesch Reading Ease Formula specifically for spanish.\nThe results can be interpreted similarly\n\n\u003e Further reading on\n[This blog post](https://legible.es/blog/lecturabilidad-fernandez-huerta/)\n\n#### Índice de perspicuidad de Szigriszt-Pazos (Spanish)  \n\n```python\ntextstat.szigriszt_pazos(text)\n```\nAdaptation of Flesch Reading Ease formula for spanish-based texts.\n\nAttempts to quantify how understandable a text is.\n\n\u003e Further reading on\n[This blog post](https://legible.es/blog/perspicuidad-szigriszt-pazos/)\n\n#### Fórmula de comprensibilidad de Gutiérrez de Polini (Spanish)  \n\n```python\ntextstat.gutierrez_polini(text)\n```\n\nReturns the Gutiérrez de Polini understandability index.\n\nSpecifically designed for the texts in spanish, not an adaptation.\nConceived for grade-school level texts.\n\nScores for more complex text are not reliable.\n\n\u003e Further reading on\n[This blog post](https://legible.es/blog/comprensibilidad-gutierrez-de-polini/)\n\n#### Fórmula de Crawford (Spanish)  \n\n```python\ntextstat.crawford(text)\n```\n\nReturns the Crawford score for the text.\n\nReturns an estimate of the years of schooling required to understand the text.\n\nThe text is only valid for elementary school level texts.\n\n\u003e Further reading on\n[This blog post](https://legible.es/blog/formula-de-crawford/)\n\n#### Osman (Arabic)\n\n```python\ntextstat.osman(text)\n```\n\nReturns OSMAN score for text.\n\nDesigned for Arabic, an adaption of Flesch and Fog Formula.\nIntroduces a new factor called \"Faseeh\".\n\n\u003e Further reading in\n[This academic paper](https://www.aclweb.org/anthology/L16-1038.pdf)\n\n#### Gulpease Index (Italian)\n\n```python\ntextstat.gulpease_index(text)\n```\n\nReturns the Gulpease index of Italian text, which translates to \nlevel of education completed.\n\nLower scores require higher level of education to read with ease.\n\n\u003e Further reading on\n[Wikipedia](https://it.wikipedia.org/wiki/Indice_Gulpease)\n\n#### Wiener Sachtextformel (German)\n\n```python\ntextstat.wiener_sachtextformel(text, variant)\n```\n\nReturns a grade level score for the given text.\n\nA value of 4 means very easy text, whereas 15 means very difficult text.\n\n\u003e Further reading on\n[Wikipedia](https://de.wikipedia.org/wiki/Lesbarkeitsindex#Wiener_Sachtextformel)\n\n### Aggregates and Averages\n\n#### Syllable Count\n\n```python\ntextstat.syllable_count(text)\n```\n\nReturns the number of syllables present in the given text.\n\nUses the Python module [Pyphen](https://github.com/Kozea/Pyphen)\nfor syllable calculation in most languages, but defaults to\n[nltk.corpus.cmudict](https://www.nltk.org/) for\nen_US.\n\n#### Lexicon Count\n\n```python\ntextstat.lexicon_count(text, removepunct=True)\n```\n\nCalculates the number of words present in the text.\nOptional `removepunct` specifies whether we need to take\npunctuation symbols into account while counting lexicons.\nDefault value is `True`, which removes the punctuation\nbefore counting lexicon items.\n\n#### Sentence Count\n\n```python\ntextstat.sentence_count(text)\n```\n\nReturns the number of sentences present in the given text.\n\n#### Character Count\n\n```python\ntextstat.char_count(text, ignore_spaces=True)\n```\n\nReturns the number of characters present in the given text.\n\n#### Letter Count\n\n```python\ntextstat.letter_count(text, ignore_spaces=True)\n```\n\nReturns the number of characters present in the given text without punctuation.\n\n#### Polysyllable Count\n\n```python\ntextstat.polysyllabcount(text)\n```\n\nReturns the number of words with a syllable count greater than or equal to 3.\n\n#### Monosyllable Count\n\n```python\ntextstat.monosyllabcount(text)\n```\n\nReturns the number of words with a syllable count equal to one.\n\n## Contributing\n\nIf you find any problems, you should open an\n[issue](https://github.com/shivam5992/textstat/issues).\n\nIf you can fix an issue you've found, or another issue, you should open\na [pull request](https://github.com/shivam5992/textstat/pulls).\n\n1. Fork this repository on GitHub to start making your changes to the master\nbranch (or branch off of it).\n2. Write a test which shows that the bug was fixed or that the feature works as expected.\n3. Send a pull request!\n\n### Development setup\n\n\u003e It is recommended you use a [virtual environment](\nhttps://docs.python.org/3/tutorial/venv.html), or [Pipenv](\nhttps://docs.pipenv.org/) to keep your development work isolated from your\nsystems Python installation.\n\n```bash\n$ git clone https://github.com/\u003cyourname\u003e/textstat.git  # Clone the repo from your fork\n$ cd textstat\n$ pip install -r requirements.txt  # Install all dependencies\n\n$ # Make changes\n\n$ python -m pytest test.py  # Run tests\n```\n\n","funding_links":[],"categories":["Python","其他_NLP自然语言处理"],"sub_categories":["其他_文本生成、文本对话"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftextstat%2Ftextstat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftextstat%2Ftextstat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftextstat%2Ftextstat/lists"}