Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def demo(self):
self = ReadabilityTool()
text = """
It is for us the living, rather,
to be dedicated here to the unfinished
work which they who fought here have
thus far so nobly advanced. It is
rather for us to be here dedicated
to the great task remaining before us,
that from these honored dead we take
increased devotion to that cause for which they
gave the last full measure of devotion, that we
here highly resolve that these dead shall not have
died in vain, that this nation, under God, shall have a
new birth of freedom, and that government of the people, by
the people, for the people, shall not perish from this earth.
"""
def demo():
ReadabilityTool.demo()
def getFleshKincaidGradeLevel(text):
'''
Get the grade reading level of a piece of text. This relies on patched ntlk_contrib
code, stored in the mediacloud.readability module (cause the published code don't
work!).
'''
r = ReadabilityTool()
gradeLevel = None
if isEnglish(text):
try:
if (text!=None) and (len(text)>0) :
gradeLevel = r.FleschKincaidGradeLevel(text.encode('utf-8'))
except (KeyError, UnicodeDecodeError):
pass
return gradeLevel