https://github.com/andreasvc/readability

Measure the readability of a given text using surface characteristics

https://github.com/andreasvc/readability

Science Score: 10.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 8 committers (12.5%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.0%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

Measure the readability of a given text using surface characteristics

Basic Info
  • Host: GitHub
  • Owner: andreasvc
  • License: other
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 131 KB
Statistics
  • Stars: 79
  • Watchers: 3
  • Forks: 17
  • Open Issues: 0
  • Releases: 0
Fork of mmautner/readability
Created over 12 years ago · Last pushed over 1 year ago
Metadata Files
Readme License

README.rst

Readability
===========

An implementation of traditional readability measures based on simple 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
word-tokenized text. The syllabification and word type recognition are based on
simple heuristics and only provides a rough measure. The supported languages
are English, German, and Dutch. Adding support for a new language involves the
addition of heuristics for the aforementioned syllabification and word type
recognition; see ``langdata.py``.

NB: all readability formulas were developed for English, so the scales of the
outcomes are only meaningful for English texts. The Dale-Chall measure uses the
original word list for English, but for Dutch and German lists of frequent
words are used that were not specifically selected for recognizability by
school children.

For syntactic complexity measures, see
`udstyle `_

Installation
------------
::

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

Usage
-----
The following preprocessing is expected:

- Tokens (words or punctuation) separated by space
- One sentence per line; no line breaks within sentences
- Paragraphs separated by one empty line

The quality of preprocessing affects the validity of the results.

From Python; tokenization using `syntok `_:

.. code:: python

    >>> import readability
    >>> import syntok.segmenter as segmenter
    >>> text = """
    This is an example sentence. Note that tokens will be separated by spaces
    and sentences by newlines.

    This is the second paragraph."""
    >>> tokenized = '\n\n'.join(
         '\n'.join(' '.join(token.value for token in sentence)
            for sentence in paragraph)
         for paragraph in segmenter.analyze(text))
    >>> print(tokenized)
    This is an example sentence .
    Note that tokens will be separated by spaces and sentences by newlines .

    This is the second paragraph .
    >>> results = readability.getmeasures(tokenized, lang='en')
    >>> print(results['readability grades']['FleschReadingEase'])
    68.64621212121216

Command line usage::

    $ readability --help
    Simple readability measures.

    Usage: readability [--lang=] [FILE]
    or: readability [--lang=] --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=   Set language (available: de, nl, en).
      --csv            Produce a table in comma separated value format on
                       standard output given one or more filenames.
      --tokenizer=  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.

Recommended tokenizers:

- For English and German, I recommend "tokenizer",
  cf. http://moin.delph-in.net/WeSearch/DocumentParsing
- For Dutch, I recommend the tokenizer that is part of the Alpino parser:
  http://www.let.rug.nl/vannoord/alp/Alpino/.
- ``ucto`` is a  general multilingual tokenizer: http://ilk.uvt.nl/ucto

Example using ``ucto``::

    $ ucto -L en -n -s "''" "CONRAD, Joseph - Lord Jim.txt" | readability
    [...]
    readability grades:
        Kincaid:                          5.44
        ARI:                              6.39
        Coleman-Liau:                     6.91
        FleschReadingEase:               85.17
        GunningFogIndex:                  9.86
        LIX:                             31.98
        SMOGIndex:                        9.39
        RIX:                              2.56
        DaleChallIndex:                   8.02
    sentence info:
        characters_per_word:              4.17
        syll_per_word:                    1.24
        words_per_sentence:              16.35
        sentences_per_paragraph:         11.5
        type_token_ratio:                 0.09
        characters:                  551335
        syllables:                   164205
        words:                       132211
        wordtypes:                    12071
        sentences:                     8087
        paragraphs:                     703
        long_words:                   20670
        complex_words:                10990
        complex_words_dc:             29908
    word usage:
        tobeverb:                      3907
        auxverb:                       1630
        conjunction:                   4398
        pronoun:                      18092
        preposition:                  19290
        nominalization:                1167
    sentence beginnings:
        pronoun:                       2578
        interrogative:                  217
        article:                        629
        subordination:                  120
        conjunction:                    236
        preposition:                    397

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
7. https://en.wikipedia.org/wiki/Dale%E2%80%93Chall_readability_formula

For better readability measures, consider the following:

- Collins-Thompson & Callan (2004). A language modeling approach to predicting reading difficulty.
  In Proc. of HLT/NAACL, pp. 193-200. http://aclweb.org/anthology/N04-1025.pdf
- Schwarm & Ostendorf (2005). Reading level assessment using SVM and statistical language models.
  Proc. of ACL, pp. 523-530. http://www.aclweb.org/anthology/P05-1065.pdf
- The Lexile framework for reading. http://www.lexile.com
- Coh-Metrix. http://cohmetrix.memphis.edu/
- Stylene: http://www.clips.ua.ac.be/category/projects/stylene
- T-Scan: http://languagelink.let.uu.nl/tscan

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

Owner

  • Name: Andreas van Cranenburgh
  • Login: andreasvc
  • Kind: user
  • Location: Groningen

GitHub Events

Total
  • Issues event: 5
  • Watch event: 11
  • Issue comment event: 3
Last Year
  • Issues event: 5
  • Watch event: 11
  • Issue comment event: 3

Committers

Last synced: over 3 years ago

All Time
  • Total Commits: 61
  • Total Committers: 8
  • Avg Commits per committer: 7.625
  • Development Distribution Score (DDS): 0.246
Top Committers
Name Email Commits
Andreas van Cranenburgh a****s@u****l 46
Max Mautner m****r@g****m 8
Rama Roberto b****i@g****m 2
Max Mautner m****b@g****m 1
Andreas van Cranenburgh A****h@u****l 1
Lukasz Ptak l****k@n****m 1
Brian Ray b****y@g****m 1
Nathaniel Case q****s@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 8
  • Total pull requests: 3
  • Average time to close issues: 5 months
  • Average time to close pull requests: 1 day
  • Total issue authors: 7
  • Total pull request authors: 3
  • Average comments per issue: 1.88
  • Average comments per pull request: 1.33
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • tom9358 (2)
  • aetherwu (1)
  • brianray (1)
  • andreasvc (1)
  • Irazall (1)
  • StylishTriangles (1)
  • bhashithe (1)
Pull Request Authors
  • StylishTriangles (1)
  • ramaroberto (1)
  • brianray (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 6
  • Total downloads:
    • pypi 28,745 last-month
  • Total dependent packages: 8
    (may contain duplicates)
  • Total dependent repositories: 59
    (may contain duplicates)
  • Total versions: 10
  • Total maintainers: 2
pypi.org: readability

Measure the readability of a given text using surface characteristics

  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 59
  • Downloads: 28,745 Last month
Rankings
Dependent repos count: 1.9%
Downloads: 3.1%
Average: 6.7%
Stargazers count: 8.3%
Dependent packages count: 10.0%
Forks count: 10.2%
Maintainers (1)
Last synced: 11 months ago
proxy.golang.org: github.com/andreasvc/readability
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 7.0%
Average: 8.2%
Dependent repos count: 9.3%
Last synced: 11 months ago
alpine-v3.13: py3-readability

Measure the readability of a given text using surface characteristics

  • Versions: 1
  • Dependent Packages: 2
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 6.2%
Average: 8.5%
Stargazers count: 12.9%
Forks count: 14.8%
Maintainers (1)
Last synced: 12 months ago
alpine-v3.14: py3-readability

Measure the readability of a given text using surface characteristics

  • Versions: 1
  • Dependent Packages: 2
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 7.6%
Average: 9.1%
Stargazers count: 13.3%
Forks count: 15.3%
Maintainers (1)
Last synced: 12 months ago
alpine-v3.15: py3-readability

Measure the readability of a given text using surface characteristics

  • Versions: 1
  • Dependent Packages: 2
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Average: 10.6%
Dependent packages count: 10.9%
Stargazers count: 14.7%
Forks count: 16.8%
Maintainers (1)
Last synced: 12 months ago
alpine-v3.12: py3-readability

Measure the readability of a given text using surface characteristics

  • Versions: 1
  • Dependent Packages: 2
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Stargazers count: 11.1%
Average: 11.3%
Forks count: 12.8%
Dependent packages count: 21.5%
Maintainers (1)
Last synced: 12 months ago