Skip to main content

Measure the readability of a given text using surface characteristics

Project description

A collection of functions that measure the readability of a given body of text using surface characteristics. These measures are basically linear regressions based on the number of words, syllables, and sentences.

The functionality is modeled after the UNIX style(1) command. Compared to the implementation as part of GNU diction, this version supports UTF-8 encoded text, but expects sentence-segmented and tokenized text. The syllabification and word type recognition is based on simple heuristics and only provides a rough measure.

NB: all readability formulas were developed for English, so the scales of the outcomes are only meaningful for English texts.

Installation

$ pip install https://github.com/andreasvc/readability/tarball/master

Usage

$ readability --help
Simple readability measures.

Usage: readability [--lang=<x>] [FILE]
or: readability [--lang=<x>] --csv FILES...

By default, input is read from standard input.
Text should be encoded with UTF-8,
one sentence per line, tokens space-separated.

Options:
  -L, --lang=<x>   Set language (available: de, nl, en).
  --csv            Produce a table in comma separated value format on
                   standard output given one or more filenames.
  --tokenizer=<x>  Specify a tokenizer including options that will be given
                   each text on stdin and should return tokenized output on
                   stdout. Not applicable when reading from stdin.

For proper results, the text should be tokenized.

Example using ucto:

$ ucto -L en -n -s '' "CONRAD, Joseph - Lord Jim.txt" | readability
[...]
readability grades:
    Kincaid:                     4.95
    ARI:                         5.78
    Coleman-Liau:                6.87
    FleschReadingEase:          86.18
    GunningFogIndex:             9.4
    LIX:                        30.97
    SMOGIndex:                   9.2
    RIX:                         2.39
sentence info:
    characters_per_word:         4.19
    syll_per_word:               1.25
    words_per_sentence:         14.92
    sentences_per_paragraph:        12.6
    characters:             552074
    syllables:              164207
    words:                  131668
    sentences:                8823
    paragraphs:                700
    long_words:              21122
    complex_words:           11306
word usage:
    tobeverb:                 3909
    auxverb:                  1632
    conjunction:              4413
    pronoun:                 18104
    preposition:             19271
    nominalization:           1216
sentence beginnings:
    pronoun:                  2593
    interrogative:             215
    article:                   632
    subordination:             124
    conjunction:               240
    preposition:               404

The option --csv collects readability measures for a number of texts in a table. To tokenize documents on-the-fly when using this option, use the --tokenizer option. Example with the “tokenize” tool:

$ readability --csv --tokenizer='tokenizer -L en-u8 -P -S -E "" -N' */*.txt >readabilitymeasures.csv

References

The following readability metrics are included:

  1. http://en.wikipedia.org/wiki/Automated_Readability_Index

  2. http://en.wikipedia.org/wiki/SMOG

  3. http://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_Grade_Level#Flesch.E2.80.93Kincaid_Grade_Level

  4. http://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_test#Flesch_Reading_Ease

  5. http://en.wikipedia.org/wiki/Coleman-Liau_Index

  6. http://en.wikipedia.org/wiki/Gunning-Fog_Index

For better readability measures, consider the following:

Acknowledgments

The code is based on: https://github.com/mmautner/readability

Which in turn was based on: https://github.com/nltk/nltk_contrib/tree/master/nltk_contrib/readability

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

readability-0.2.tar.gz (10.8 kB view details)

Uploaded Source

File details

Details for the file readability-0.2.tar.gz.

File metadata

  • Download URL: readability-0.2.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for readability-0.2.tar.gz
Algorithm Hash digest
SHA256 2246350df2b095c3b5859785ffd6140409a51f7f02b659fb1a1be60dcc88b8e7
MD5 cf87a608385ab8dd6e5b7d65119be128
BLAKE2b-256 108c869de6d3e4b7afdaa1d21ec83c10cf859c71267f3596a4c6f3c192f3c34e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page