Coder Social home page Coder Social logo

textstat's Introduction

textstat

Python package to calculate statistics from text, which helps to decide readability, complexity and grade level of a particular corpus.

Install

You can install textstat either via the Python Package Index (PyPI) or from source.

To install using pip:

$ pip install textstat

To install using easy_install:

$ easy_install textstat

Downloading and installing from source

Download the latest version of textstat from http://pypi.python.org/pypi/textstat/

You can install it by doing the following,:

$ tar xfz textstat-*.tar.gz

$ cd textstat-*/

$ python setup.py build

$ python setup.py install # as root

List of Functions

Syllable Count

function name - syllable_count(text)

returns - the number of syllables present in the given text.

Lexicon Count

function name - lexicon_count(text, TRUE/FALSE)

Calculates the number of words present in the text. TRUE/FALSE specifies whether we need to take in account in punctuation symbols while counting lexicons or not. Default value is TRUE, which removes the punctuation before counting lexicons.

Sentence Count

function name - sentence_count(text)

returns the number of sentences present in the given text.

The Flesch Reading Ease formula

function name - flesch_reading_ease(text)

returns the Flesch Reading Ease Score. Following table is helpful to access the ease of readability in a document.

  • 90-100 : Very Easy
  • 80-89 : Easy
  • 70-79 : Fairly Easy
  • 60-69 : Standard
  • 50-59 : Fairly Difficult
  • 30-49 : Difficult
  • 0-29 : Very Confusing

The The Flesch-Kincaid Grade Level

function name - flesch_kincaid_grade(text)

returns the grade score using the Flesch-Kincaid Grade Formula. For example a score of 9.3 means that a ninth grader would be able to read the document.

The Fog Scale (Gunning FOG Formula)

function name - gunning_fog(text) returns the FOG index of the given text.

The SMOG Index

function name - smog_index(text)

return the SMOG index of the given text.

Automated Readability Index

function name - automated_readability_index(text)

returns the ARI(Automated Readability Index) which outputs a number that approximates the grade level needed to comprehend the text. For example if the ARI is 6.5, then the grade level to comprehend the text is 6th to 7th grade.

The Coleman-Liau Index

function name - coleman_liau_index(text)

returns the grade level of the text using the Coleman-Liau Formula

Linsear Write Formula

function name - linsear_write_formula(text)

returns the grade level using the Lisear Write Formula

Dale-Chall Readability Score

function name - dale_chall_readability_score(text)

Different from other tests, since it uses a lookup table of most commonly used 3000 english words. Thus it returns the grade level using the New Dale-Chall Formula.

Readability Consensus based upon all the above tests

function name - readability_consensus(text) Based upon all the above tests returns the best grade level under which the given text belongs to.

Usage

from textstat.textstat import textstat
if __name__ == '__main__':
		test_data = """Playing games has always been thought to be important to the development of well-balanced and creative children; however, what part, if any, they should play in the lives of adults has never been researched that deeply. I believe that playing games is every bit as important for adults as for children. Not only is taking time out to play games with our children and other adults valuable to building interpersonal relationships but is also a wonderful way to release built up tension."""

	print textstat.flesch_reading_ease(test_data)
	print textstat.smog_index(test_data)
	print textstat.flesch_kincaid_grade(test_data)	print textstat.coleman_liau_index(test_data)
	print textstat.automated_readability_index(test_data)
	print textstat.dale_chall_readability_score(test_data)
	print textstat.difficult_words(test_data)
	print textstat.linsear_write_formula(test_data)
	print textstat.gunning_fog(test_data)
	print textstat.text_standard(test_data)

the arguement (text) for all the functions defined remains same - i.e the text for which statistics needs to be calculated

textstat's People

Contributors

shivam5992 avatar massvoice avatar lowks avatar

Watchers

Corey Thompson avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.