Clarity of writing

Introduction

The clarity of writing module assesses the readability, grammatical correctness and sentiment of a given body of text.

Usage

To use the module:

>>> import coast_core
>>> coast_core.clarity_of_writing.function(to_use)

or:

>>> from coast_core import clarity_of_writing
>>> clarity_of_writing.function(to_use)

Functions

A collection of functions that can be used for analysing the clarity of writing within an article

coast_core.clarity_of_writing.analyse_readability_metrics(article_text)

Use the textstat library to report multiple readability measures.

The readability metrics analysed are: * The Flesch Reading Ease Score. A score from 100 (very easy to read) to 0 (very confusing). * 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 index of the given text * The SMOG index of the given text * 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 grade level of the text using the Coleman-Liau Formula * The grade level using the Lisear Write Formula * The grade level using the New Dale-Chall Formula.

Parameters:article_text – The article text to operate on.
Returns:An object containing all measures
coast_core.clarity_of_writing.analyse_text_for_grammatical_metrics(article_text)

Use the language_check library to check a body of text for grammatical issues.

Parameters:article_text – The text to be analyse.
Returns:The total number of grammatical issues found. A list containing details of each grammatical issue. A list of sentences, tokenized by NLTK.
coast_core.clarity_of_writing.detect_language(text)

Given a body of text, will use the langdetect library to detect the text language and return.

Parameters:text – The body of text to analyse.
Returns:The language code (e.g. EN for English).
coast_core.clarity_of_writing.execute_clarity_of_writing_check(article_text)

Runs a complete end-to-end analysis of clarity of writing using all other functions.

Parameters:article_text – The article text to operate on.
Returns:An object containing language, readability, grammar and sentiment
coast_core.clarity_of_writing.run_sentiment_check(article_text)

Run sentiment analysis over the article.

Parameters:article_text – The article text to operate on.
Returns:An object that contain polarity and subjectivity. Polarity, also known as orientation is he emotion expressed in the sentence. It can be positive, neagtive or neutral. Subjectivity is when text is an explanatory article which must be analysed in context.