Test Content Readability from a Text File

in #programming6 years ago

readable.png

If you recall I showed how to test the readability of some written content using Python.

In the comments, I was asked if it would be possible to read a text file rather than provide a URL.

Well, here is the code to do that :)

Code:

https://gist.github.com/omiq/e3722435dd9cb3b719f33f3970edda4b

# this is the important library that acutally does the work
from textstat.textstat import textstat

with open('testfile.txt', 'r') as content_file:
    test_string = content_file.read()

# show what we grabbed
print( test_string )
print()

# So how readable is it?
print( str(textstat.flesch_reading_ease(test_string)) + " /100" )

Sort:  

This is great, thanks!

As this version reads from a file, I guess one don't have to import html2text?

And to read the path to the file I want to test I added:

test_file = sys.argv[1]

and changed the 'with open' line to

with open(test_file, 'r') as content_file:

That way its quick and easy to just run python read.py /path/to/testfile.txt to check a file.

Quick, easy and fun way to check readability before publishing. Who knows, maybe it will improve my writing?

Congratulations @makerhacks! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes received

Click on any badge to view your own Board of Honor on SteemitBoard.

To support your work, I also upvoted your post!
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!

Coin Marketplace

STEEM 0.29
TRX 0.12
JST 0.034
BTC 63453.92
ETH 3283.73
USDT 1.00
SBD 3.89