NOTE: Before running this notebook, be sure to place your copy of the play in the same folder as the notebook.
pip install textatistic
from pathlib import Path
text = Path('RomeoAndJuliet.txt').read_text()
from textatistic import Textatistic
readability = Textatistic(text)
Textatistic
method dict
returns a dictionary containing various statistics and the readability scores: %precision 3
readability.dict()
Textatistic
property of the same name as the keys shown in the preceding output. The statistics produced include: char_count
—number of characters word_count
—number of words sent_count
—number of sentences sybl_count
—number of syllables notdalechall_count
—# of words not on the Dale-Chall list (words understood by 80% of 5th graders) polysyblword_count
—# of words with 3+ syllablesflesch_score
—Flesch Reading Ease scorefleschkincaid_score
—Flesch-Kincaid score corresponds to a specific grade levelgunningfog_score
—Gunning Fog index value corresponds to a specific grade levelsmog_score
—Simple Measure of Gobbledygook (SMOG)dalechall_score
—Dale-Chall score©1992–2020 by Pearson Education, Inc. All Rights Reserved. This content is based on Chapter 5 of the book Intro to Python for Computer Science and Data Science: Learning to Program with AI, Big Data and the Cloud.
DISCLAIMER: The authors and publisher of this book have used their best efforts in preparing the book. These efforts include the development, research, and testing of the theories and programs to determine their effectiveness. The authors and publisher make no warranty of any kind, expressed or implied, with regard to these programs or to the documentation contained in these books. The authors and publisher shall not be liable in any event for incidental or consequential damages in connection with, or arising out of, the furnishing, performance, or use of these programs.