Determine the “Readability” of a text with Python

George Klare (1963) defines readability as “the ease of understanding or comprehension due to the style of writing.”

Readability, although somewhat subjective, has been a well researched topic dating back to the 1920s. Since then, researchers have crafted a number of readability formulas that attempt to accurately identify the readability of a text.

Readability metrics have numerous uses. A writer might use the metrics to objectively assess the complexity of his work to determine whether it’s written at a level appropriate for his intended audience. An educational software firm might use readability metrics to recommend level-appropriate content for its students.

Currently, I work on the latter. As a result, I’ve written a Python package, py-readability-metrics that assesses the readability of a given text, using a variety of today’s most popular readability metrics. These include:

  • Flesch Kincaid Grade Level
  • Flesch Reading Ease
  • Dale Chall Readability
  • Automated Readability Index (ARI)
  • Coleman Liau Index
  • Gunning Fog
  • SMOG
  • Linear Write

Given a text, each of the above metrics calculate a score indicating the difficulty of the text. Often, the score is mapped to a grade level e.g.. kindergarten, first grade, …, through college graduate.

py-readability-metrics implements the above formulas and calculates their scores. Additionally, it enables one to easily interpret each score by reporting its grade level(s) mapping. For example, a “Flesch Reading Ease” score of 80 indicates that the text is written at a 6th grade reading level. A “Flesch-Kincaid Grade Level” score of 6.4 also indicates a 6th grade reading level.

Let’s see a few examples

To install the package, use pip:

  • pip install py-readability-metrics installs the module
  • python -m nltk.downloader installs a punctuation module

Now that we’ve installed the module, let’s see how to assess a text using the Flesch Kincaid Grade Level metric

To install the package, use pip:

And now, with assess the same text, using the SMOG Index

py-readability-metrics provides simple api that enables developers to easily assess the readability of a given text using a variety of popular metrics.

If you dig the project, star it on GitHub!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *