Readability of various publications
In this exercise, you have been given excerpts of articles from four publications. Your task is to compute the readability of these excerpts using the Gunning fog score and consequently, determine the relative difficulty of reading these publications.
The excerpts are available as the following strings:
forbes- An excerpt from an article from Forbes magazine on the Chinese social credit score system.harvard_law- An excerpt from a book review published in Harvard Law Review.r_digest- An excerpt from a Reader's Digest article on flight turbulence.time_kids- An excerpt from an article on the ill effects of salt consumption published in TIME for Kids.
Deze oefening maakt deel uit van de cursus
Feature Engineering for NLP in Python
Oefeninstructies
- Import the
Readabilityclass fromreadability. - Compute the
gfobject for eachexcerptusing thegunning_fog()method onReadability. - Compute the Gunning fog score using the the
scoreattribute. - Print the list of Gunning fog scores.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Import Readability
from readability import Readability
# List of excerpts
excerpts = [forbes, harvard_law, r_digest, time_kids]
# Loop through excerpts and compute gunning fog index
gunning_fog_scores = []
for excerpt in excerpts:
gf = Readability(excerpt).____()
gf_score = gf.____
gunning_fog_scores.append(gf_score)
# Print the gunning fog indices
print(gunning_fog_scores)