• Stars
    star
    281
  • Rank 147,023 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ“— Score text readability using a number of formulas: Flesch-Kincaid Grade Level, Gunning Fog, ARI, Dale Chall, SMOG, and more

πŸ“— py-readability-metrics

Travis Build Python Documentation Status wheel All Contributors MIT license

Score the readability of text using popular readability formulas and metrics including: Flesch Kincaid Grade Level, Flesch Reading Ease, Gunning Fog Index, Dale Chall Readability, Automated Readability Index (ARI), Coleman Liau Index, Linsear Write, SMOG, and SPACHE. πŸ“—

GitHub stars Twitter URL

Install

pip install py-readability-metrics
python -m nltk.downloader punkt

Usage

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

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:

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:

r.flesch_kincaid()

example:

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:

r.flesch()

example:

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:

r.dale_chall()

example:

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:

r.ari()

example:

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:

r.coleman_liau()

example:

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:

r.gunning_fog()

example:

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:

r.smog()

example:

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:

r.smog(all_sentences=True)

example:

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:

r.spache()

example:

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:

r.linsear_write()

example:

lw = r.linsear_write()
print(lw.score)
print(lw.grade_level)

Contributing

Contributions are welcome!

References

License

MIT

Buy Me A Coffee

Contributors ✨

Thanks goes to these wonderful people (emoji key):


rbamos

πŸ’» ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

More Repositories

1

express-openapi-validator

πŸ¦‹ Auto-validates api requests, responses, and securities using ExpressJS and an OpenAPI 3.x specification
TypeScript
914
star
2

generator-express-no-stress

πŸš‚ A Yeoman generator for Express.js based 12-factor apps and apis
JavaScript
579
star
3

dotenv-kotlin

πŸ—οΈ Dotenv is a module that loads environment variables from a .env file
Kotlin
414
star
4

generator-express-no-stress-typescript

πŸš„ A Yeoman generator for Express.js based 12-factor apps and apis using Typescript
TypeScript
348
star
5

dotenv-java

πŸ—οΈ Dotenv is a no-dep, pure Java module that loads environment variables from a .env file
Java
308
star
6

kotlin-openapi-spring-functional-template

πŸƒ Kotlin Spring 5 Webflux functional application with api request validation and interactive api doc
Kotlin
177
star
7

essence

Automatically extract the main text content (and more) from an HTML document
Kotlin
105
star
8

uuid-mongodb

πŸ“‡ Generates and parses MongoDB BSON UUIDs
JavaScript
97
star
9

openapi-spring-webflux-validator

🌱 A friendly kotlin library to validate API endpoints using an OpenApi 3.0 and Swagger 2.0 specification
Kotlin
93
star
10

node-mongodb-fixtures

🍏 Setup and tear down test fixtures with MongoDB.
JavaScript
90
star
11

lambda-zsh-theme

Ξ» Beautiful lambda theme for Zsh
58
star
12

nationalparks_conversation

Chatbots and Watson: Let’s talk about national parks: course source code
JavaScript
46
star
13

java-dotenv

Use dotenv-java or dotenv-kotlin https://github.com/cdimascio/dotenv-java or https://github.com/cdimascio/dotenv-kotlin instead
24
star
14

kotlin-spring-mvc-template

12-factor compliant Spring MVC Kotlin template. Features automatic request/response validation and interactive API doc
Kotlin
22
star
15

react-native-share-sheet

iOS share sheet for React Native
Objective-C
11
star
16

dbpedia-sparql-client

A promisified DBpedia SPARQL client that keeps it simple.
JavaScript
10
star
17

express-openapi-validator-example

simple openapi validation examplewith express-openapi-validator
JavaScript
9
star
18

watson-nlc-spam

Create a spam classifier with Watson Natural Language Classifier.
CSS
9
star
19

gin-openapi

Automatically validates API requests against an OpenAPI 3 spec.
Go
6
star
20

cloudant-upsert

A no-dependency module that adds 'upsert' to Node.js Cloudant
JavaScript
5
star
21

couchinator

πŸ›‹οΈ Fixtures for CouchDB and IBM Cloudant: Create and teardown cloudant dbs
JavaScript
5
star
22

japi-errors

⚑Customizable errors for RESTful and HTTP services.
Java
4
star
23

md5-nodejs

A node module that hashes data to MD5.
JavaScript
4
star
24

mongoose-compose-example

An example to quickly get your up and running with Mongoose and MongoDB on IBM Compose.io.
JavaScript
4
star
25

ya-angular-requirejs-seed

Seed for AngularJs and require.js
JavaScript
3
star
26

essence-web

JavaScript
3
star
27

couchinator-java-wrapper

Fixtures for CouchDB and IBM Cloudant.
Java
3
star
28

sqs-replay

♻️ CLI that replays AWS SQS messages between queues.
Rust
2
star
29

my-projects

A list of newsworthy projects that I led or was key contributor
2
star
30

md5-to-uuid

A node module that converts MD5 hashes to UUIDs.
JavaScript
2
star
31

aws-config-manager

Manage multiple AWS credentials and config files
Go
2
star
32

wcp-errors

Generate normalized http error messages
JavaScript
2
star
33

express-no-stress-openapi3-example

JavaScript
2
star
34

bunyan-decorator

bunyan log decorator for es6 class methods
JavaScript
1
star
35

java-dotenv-example

Java
1
star
36

scripts

Shell
1
star
37

aws-credentials-manager

Utility for managing multiple AWS credentials files.
Shell
1
star
38

woh-deploy

CSS
1
star
39

homebrew-tap

Ruby
1
star
40

rails-example

Ruby
1
star
41

docker-images

Dockerfile
1
star
42

lerna-test

JavaScript
1
star
43

flagger-on

🦩 fast, feature flags with percentage rollout
TypeScript
1
star
44

keras_nns

Python
1
star
45

cdimascio.github.io

Personal website
CSS
1
star
46

nlu-news-web

Sample application using Watson Natural Language Understand and IBM Cloud Functions
JavaScript
1
star
47

mixpanel-export-java

Lightweight export library for Mixpanel
Java
1
star
48

node-api-errors

JavaScript
1
star
49

cdimascio-card

πŸ“› Carmine's card
JavaScript
1
star
50

me-web

JavaScript
1
star
51

vue-webqr

JavaScript
1
star
52

ballparks

Source code for developerWorks article: Create a baseball-themed app powered by Weather Company Data for IBM Bluemix and DBpedia
JavaScript
1
star