# 📗 py-readability-metrics
![Travis Build](https://travis-ci.org/cdimascio/py-readability-metrics.svg?branch=master) ![Python](https://img.shields.io/badge/python-3.x-blue.svg) [![Documentation Status](https://readthedocs.org/projects/py-readability-metrics/badge/?version=latest)](https://py-readability-metrics.readthedocs.io/en/latest/?badge=latest) [![wheel](https://img.shields.io/badge/wheel-yes-ff00c9.svg)](https://pypi.org/project/py-readability-metrics/) [![](https://img.shields.io/gitter/room/cdimascio-oss/community?color=%23eb205a)](https://gitter.im/cdimascio-oss/community) [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)
[![MIT license](https://img.shields.io/badge/License-MIT-green.svg)](https://lbesson.mit-license.org/)
Score the _readability_ of text using popular readability formulas and metrics including: [Flesch Kincaid Grade Level](#flesch-kincaid-grade-level), [Flesch Reading Ease](#flesch-reading-ease), [Gunning Fog Index](#gunning-fog), [Dale Chall Readability](#dale-chall-readability), [Automated Readability Index (ARI)](#automated-readability-index-ari), [Coleman Liau Index](#coleman-liau-index), [Linsear Write](#linsear-write), [SMOG](#smog), and [SPACHE](#spache). 📗
[![GitHub stars](https://img.shields.io/github/stars/cdimascio/py-readability-metrics.svg?style=social&label=Star&maxAge=2592000)](https://GitHub.com/cdimascio/py-readability-metrics/stargazers/) [![Twitter URL](https://img.shields.io/twitter/url/https/github.com/cdimascio/py-readability-metrics.svg?style=social)](https://twitter.com/intent/tweet?text=Check%20out%20py-readability-metrics%20by%20%40CarmineDiMascio%20https%3A%2F%2Fgithub.com%2Fcdimascio%2Fpy-readability-metrics%20%F0%9F%91%8D)
<p align="center">
<img src="https://raw.githubusercontent.com/cdimascio/py-readability-metrics/master/assets/py-readability-metrics.png" width="500"></>
</p>
## Install
```shell
pip install py-readability-metrics
python -m nltk.downloader punkt
```
## Usage
```python
from readability import Readability
r = Readability(text)
r.flesch_kincaid()
r.flesch()
r.gunning_fog()
r.coleman_liau()
r.dale_chall()
r.ari()
r.linsear_write()
r.smog()
r.spache()
```
**\*Note:** `text` must contain >= 100 words\*
## Supported Metrics
- [Flesch Kincaid Grade Level](#flesch-kincaid-grade-level)
- [Flesch Reading Ease](#flesch-reading-ease)
- [Dale Chall Readability](#dale-chall-readability)
- [Automated Readability Index (ARI)](#automated-readability-index-ari)
- [Coleman Liau Index](#coleman-liau-index)
- [Gunning Fog](#gunning-fog)
- [SMOG](#smog)
- [Spache](#spache)
- [Linsear Write](#linsear-write)
## Readability Metric Details and Properties
All metrics provide a `score` attribute. Indvidual metrics provide additional properties to increased interpretability. See details below to capture per metric details.
_Note:_ In all examples below `r` is:
```python
r = Readability(text)
```
### Flesch-Kincaid Grade Level
The U.S. Army uses Flesch-Kincaid Grade Level for assessing the difficulty of technical manuals. The commonwealth of Pennsylvania uses Flesch-Kincaid Grade Level for scoring automobile insurance policies to ensure their texts are no higher than a ninth grade level of reading difficulty. Many other U.S. states also use Flesch-Kincaid Grade Level to score other legal documents such as business policies and financial forms.
**_call:_**
```python
r.flesch_kincaid()
```
**_example:_**
```python
fk = r.flesch_kincaid()
print(fk.score)
print(fk.grade_level)
```
### Flesch Reading Ease
The U.S. Department of Defense uses the Reading Ease test as the standard test of readability for its documents and forms. Florida requires that life insurance policies have a Flesch Reading Ease score of 45 or greater.
**_call:_**
```python
r.flesch()
```
**_example:_**
```python
f = r.flesch()
print(f.score)
print(f.ease)
print(f.grade_levels)
```
### Dale Chall Readability
The Dale-Chall Formula is an accurate readability formula for the simple reason that it is based on the use of familiar words, rather than syllable or letter counts. Reading tests show that readers usually find it easier to read, process and recall a passage if they find the words familiar.
**_call:_**
```python
r.dale_chall()
```
**_example:_**
```python
dc = r.dale_chall()
print(dc.score)
print(dc.grade_levels)
```
### Automated Readability Index (ARI)
Unlike the other indices, the ARI, along with the Coleman-Liau, relies on a factor of characters per word, instead of the usual syllables per word. ARI is widely used on all types of texts.
**_call:_**
```python
r.ari()
```
**_example:_**
```python
ari = r.ari()
print(ari.score)
print(ari.grade_levels)
print(ari.ages)
```
### Coleman Liau Index
The Coleman-Liau Formula usually gives a lower grade value than any of the Kincaid, ARI and Flesch values when applied to technical documents.
**_call:_**
```python
r.coleman_liau()
```
**_example:_**
```python
cl = r.coleman_liau()
print(cl.score)
print(cl.grade_level)
```
### Gunning Fog
The Gunning fog index measures the readability of English writing. The index estimates the years of formal education needed to understand the text on a first reading. A fog index of 12 requires the reading level of a U.S. high school senior (around 18 years old).
**_call:_**
```python
r.gunning_fog()
```
**_example:_**
```python
gf = r.gunning_fog()
print(gf.score)
print(gf.grade_level)
```
### SMOG
The SMOG Readability Formula (Simple Measure of Gobbledygook) is a popular method to use on health literacy materials.
**_call:_**
```python
r.smog()
```
**_example:_**
```python
s = r.smog()
print(s.score)
print(s.grade_level)
```
The original SMOG formula uses a sample of 30 sentences from the original text. However, the formula can be generalized to any number of sentences. You can use the generalized formula by passing the `all_sentences=True` argument to `smog()`
**_call:_**
```python
r.smog(all_sentences=True)
```
**_example:_**
```python
s = r.smog(all_sentences=True)
print(s.score)
print(s.grade_level)
```
### SPACHE
The Spache Readability Formula is used for Primary-Grade Reading Materials, published in 1953 in The Elementary School Journal. The Spache Formula is best used to calculate the difficulty of text that falls at the 3rd grade level or below.
**_call:_**
```python
r.spache()
```
**_example:_**
```python
s = r.spache()
print(s.score)
print(s.grade_level)
```
### Linsear Write
Linsear Write is a readability metric for English text, purportedly developed for the United States Air Force to help them calculate the readability of their technical manuals.
**_call:_**
```python
r.linsear_write()
```
**_example:_**
```python
lw = r.linsear_write()
print(lw.score)
print(lw.grade_level)
```
## [Contributing](CONTRIBUTING.md)
Contributions are welcome!
## References
- [Readability Formulas](http://readabilityformulas.com/)
## License
[MIT](LICENSE)
<a href="https://www.buymeacoffee.com/m97tA5c" target="_blank"><img src="https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://github.com/rbamos"><img src="https://avatars1.githubusercontent.com/u/49767442?v=4" width="100px;" alt=""/><br /><sub><b>rbamos</b></sub></a><br /><a href="https://github.com/cdimascio/py-readability-metrics/commits?author=rbamos" title="Code">💻</a> <a href="https://github.com/cdimascio/py-readability-metrics/commits?author=rbamos" title="Tests">⚠️</a></td>
</tr>
</table>
<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
Raw data
{
"_id": null,
"home_page": "https://github.com/ben-gray-dev/py-readability-metrics-small",
"name": "py-readability-metrics-small",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "readability metrics text difficulty grade level",
"author": "Ben Gray",
"author_email": "bgray27613@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/2f/92/e9ca94d78e1690e315b2cd05e0a1270e3c684710431e04d7917c31d876f5/py_readability_metrics_small-1.8.tar.gz",
"platform": null,
"description": "# \ud83d\udcd7 py-readability-metrics\n![Travis Build](https://travis-ci.org/cdimascio/py-readability-metrics.svg?branch=master) ![Python](https://img.shields.io/badge/python-3.x-blue.svg) [![Documentation Status](https://readthedocs.org/projects/py-readability-metrics/badge/?version=latest)](https://py-readability-metrics.readthedocs.io/en/latest/?badge=latest) [![wheel](https://img.shields.io/badge/wheel-yes-ff00c9.svg)](https://pypi.org/project/py-readability-metrics/) [![](https://img.shields.io/gitter/room/cdimascio-oss/community?color=%23eb205a)](https://gitter.im/cdimascio-oss/community) [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)\n [![MIT license](https://img.shields.io/badge/License-MIT-green.svg)](https://lbesson.mit-license.org/)\n\nScore the _readability_ of text using popular readability formulas and metrics including: [Flesch Kincaid Grade Level](#flesch-kincaid-grade-level), [Flesch Reading Ease](#flesch-reading-ease), [Gunning Fog Index](#gunning-fog), [Dale Chall Readability](#dale-chall-readability), [Automated Readability Index (ARI)](#automated-readability-index-ari), [Coleman Liau Index](#coleman-liau-index), [Linsear Write](#linsear-write), [SMOG](#smog), and [SPACHE](#spache). \ud83d\udcd7\n\n[![GitHub stars](https://img.shields.io/github/stars/cdimascio/py-readability-metrics.svg?style=social&label=Star&maxAge=2592000)](https://GitHub.com/cdimascio/py-readability-metrics/stargazers/) [![Twitter URL](https://img.shields.io/twitter/url/https/github.com/cdimascio/py-readability-metrics.svg?style=social)](https://twitter.com/intent/tweet?text=Check%20out%20py-readability-metrics%20by%20%40CarmineDiMascio%20https%3A%2F%2Fgithub.com%2Fcdimascio%2Fpy-readability-metrics%20%F0%9F%91%8D)\n\n\n<p align=\"center\">\n <img src=\"https://raw.githubusercontent.com/cdimascio/py-readability-metrics/master/assets/py-readability-metrics.png\" width=\"500\"></>\n</p>\n\n## Install\n\n```shell\npip install py-readability-metrics\npython -m nltk.downloader punkt\n```\n\n## Usage\n\n```python\nfrom readability import Readability\n\nr = Readability(text)\n\nr.flesch_kincaid()\nr.flesch()\nr.gunning_fog()\nr.coleman_liau()\nr.dale_chall()\nr.ari()\nr.linsear_write()\nr.smog()\nr.spache()\n```\n\n**\\*Note:** `text` must contain >= 100 words\\*\n\n## Supported Metrics\n\n- [Flesch Kincaid Grade Level](#flesch-kincaid-grade-level)\n- [Flesch Reading Ease](#flesch-reading-ease)\n- [Dale Chall Readability](#dale-chall-readability)\n- [Automated Readability Index (ARI)](#automated-readability-index-ari)\n- [Coleman Liau Index](#coleman-liau-index)\n- [Gunning Fog](#gunning-fog)\n- [SMOG](#smog)\n- [Spache](#spache)\n- [Linsear Write](#linsear-write)\n\n## Readability Metric Details and Properties\n\nAll metrics provide a `score` attribute. Indvidual metrics provide additional properties to increased interpretability. See details below to capture per metric details.\n\n_Note:_ In all examples below `r` is:\n\n```python\nr = Readability(text)\n```\n\n### Flesch-Kincaid Grade Level\n\nThe U.S. Army uses Flesch-Kincaid Grade Level for assessing the difficulty of technical manuals. The commonwealth of Pennsylvania uses Flesch-Kincaid Grade Level for scoring automobile insurance policies to ensure their texts are no higher than a ninth grade level of reading difficulty. Many other U.S. states also use Flesch-Kincaid Grade Level to score other legal documents such as business policies and financial forms.\n\n**_call:_**\n\n```python\nr.flesch_kincaid()\n```\n\n**_example:_**\n\n```python\nfk = r.flesch_kincaid()\nprint(fk.score)\nprint(fk.grade_level)\n```\n\n### Flesch Reading Ease\n\nThe U.S. Department of Defense uses the Reading Ease test as the standard test of readability for its documents and forms. Florida requires that life insurance policies have a Flesch Reading Ease score of 45 or greater.\n\n**_call:_**\n\n```python\nr.flesch()\n```\n\n**_example:_**\n\n```python\nf = r.flesch()\nprint(f.score)\nprint(f.ease)\nprint(f.grade_levels)\n```\n\n### Dale Chall Readability\n\nThe Dale-Chall Formula is an accurate readability formula for the simple reason that it is based on the use of familiar words, rather than syllable or letter counts. Reading tests show that readers usually find it easier to read, process and recall a passage if they find the words familiar.\n\n**_call:_**\n\n```python\nr.dale_chall()\n```\n\n**_example:_**\n\n```python\ndc = r.dale_chall()\nprint(dc.score)\nprint(dc.grade_levels)\n```\n\n### Automated Readability Index (ARI)\n\nUnlike the other indices, the ARI, along with the Coleman-Liau, relies on a factor of characters per word, instead of the usual syllables per word. ARI is widely used on all types of texts.\n\n**_call:_**\n\n```python\nr.ari()\n```\n\n**_example:_**\n\n```python\nari = r.ari()\nprint(ari.score)\nprint(ari.grade_levels)\nprint(ari.ages)\n```\n\n### Coleman Liau Index\n\nThe Coleman-Liau Formula usually gives a lower grade value than any of the Kincaid, ARI and Flesch values when applied to technical documents.\n\n**_call:_**\n\n```python\nr.coleman_liau()\n```\n\n**_example:_**\n\n```python\ncl = r.coleman_liau()\nprint(cl.score)\nprint(cl.grade_level)\n```\n\n### Gunning Fog\n\nThe Gunning fog index measures the readability of English writing. The index estimates the years of formal education needed to understand the text on a first reading. A fog index of 12 requires the reading level of a U.S. high school senior (around 18 years old).\n\n**_call:_**\n\n```python\nr.gunning_fog()\n```\n\n**_example:_**\n\n```python\ngf = r.gunning_fog()\nprint(gf.score)\nprint(gf.grade_level)\n```\n\n### SMOG\n\nThe SMOG Readability Formula (Simple Measure of Gobbledygook) is a popular method to use on health literacy materials.\n\n**_call:_**\n\n```python\nr.smog()\n```\n\n**_example:_**\n\n```python\ns = r.smog()\nprint(s.score)\nprint(s.grade_level)\n```\n\nThe original SMOG formula uses a sample of 30 sentences from the original text. However, the formula can be generalized to any number of sentences. You can use the generalized formula by passing the `all_sentences=True` argument to `smog()`\n\n**_call:_**\n\n```python\nr.smog(all_sentences=True)\n```\n\n**_example:_**\n\n```python\ns = r.smog(all_sentences=True)\nprint(s.score)\nprint(s.grade_level)\n```\n\n### SPACHE\n\nThe Spache Readability Formula is used for Primary-Grade Reading Materials, published in 1953 in The Elementary School Journal. The Spache Formula is best used to calculate the difficulty of text that falls at the 3rd grade level or below. \n\n**_call:_**\n\n```python\nr.spache()\n```\n\n**_example:_**\n\n```python\ns = r.spache()\nprint(s.score)\nprint(s.grade_level)\n```\n\n### Linsear Write\n\nLinsear Write is a readability metric for English text, purportedly developed for the United States Air Force to help them calculate the readability of their technical manuals.\n\n**_call:_**\n\n```python\nr.linsear_write()\n```\n\n**_example:_**\n\n```python\nlw = r.linsear_write()\nprint(lw.score)\nprint(lw.grade_level)\n```\n\n## [Contributing](CONTRIBUTING.md)\n\nContributions are welcome!\n\n## References\n\n- [Readability Formulas](http://readabilityformulas.com/)\n\n## License\n\n[MIT](LICENSE)\n\n<a href=\"https://www.buymeacoffee.com/m97tA5c\" target=\"_blank\"><img src=\"https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/orange_img.png\" alt=\"Buy Me A Coffee\" style=\"height: auto !important;width: auto !important;\" ></a>\n\n## Contributors \u2728\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n <tr>\n <td align=\"center\"><a href=\"https://github.com/rbamos\"><img src=\"https://avatars1.githubusercontent.com/u/49767442?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>rbamos</b></sub></a><br /><a href=\"https://github.com/cdimascio/py-readability-metrics/commits?author=rbamos\" title=\"Code\">\ud83d\udcbb</a> <a href=\"https://github.com/cdimascio/py-readability-metrics/commits?author=rbamos\" title=\"Tests\">\u26a0\ufe0f</a></td>\n </tr>\n</table>\n\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Score text \"Readability\" with popular formulas and metrics including Flesch-Kincaid, Gunning Fog, ARI, Dale Chall, SMOG, Spache and more",
"version": "1.8",
"project_urls": {
"Homepage": "https://github.com/ben-gray-dev/py-readability-metrics-small"
},
"split_keywords": [
"readability",
"metrics",
"text",
"difficulty",
"grade",
"level"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2f92e9ca94d78e1690e315b2cd05e0a1270e3c684710431e04d7917c31d876f5",
"md5": "5a79291f13018bfbcf86f197d73e5a3b",
"sha256": "556980df74262a89841c3ca00877e544167ce8f54fa95a51aebe48af0b9db05e"
},
"downloads": -1,
"filename": "py_readability_metrics_small-1.8.tar.gz",
"has_sig": false,
"md5_digest": "5a79291f13018bfbcf86f197d73e5a3b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 21559,
"upload_time": "2024-04-23T00:55:29",
"upload_time_iso_8601": "2024-04-23T00:55:29.786308Z",
"url": "https://files.pythonhosted.org/packages/2f/92/e9ca94d78e1690e315b2cd05e0a1270e3c684710431e04d7917c31d876f5/py_readability_metrics_small-1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-23 00:55:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ben-gray-dev",
"github_project": "py-readability-metrics-small",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"lcname": "py-readability-metrics-small"
}