Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -205,7 +205,7 @@ def flesch_kincaid_grade_level(text):
|
|
205 |
return 0.39 * (words / sentences_count) + 11.8 * (syllables / words) - 15.59
|
206 |
|
207 |
def flesch_reading_ease(text):
|
208 |
-
|
209 |
words = extract_words(sentences)
|
210 |
syllables = sum([count_syllables(word) for word in text.split()])
|
211 |
|
@@ -214,7 +214,7 @@ def flesch_reading_ease(text):
|
|
214 |
return 206.835 - 1.015 * (words / sentences_count) - 84.6 * (syllables / words)
|
215 |
|
216 |
def gunning_fog_index(text):
|
217 |
-
|
218 |
words = extract_words(sentences)
|
219 |
complex_words = len([word for word in text.split() if count_syllables(word) >= 3])
|
220 |
|
@@ -223,10 +223,9 @@ def gunning_fog_index(text):
|
|
223 |
return 0.4 * ((words / sentences_count) + 100 * (complex_words / words))
|
224 |
|
225 |
def calculate_readability_metrics(text):
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
gunning_fog = gunning_fog_index(preprocessed_text)
|
230 |
|
231 |
return fk_grade_level, fk_reading_ease, gunning_fog
|
232 |
#-------------#
|
|
|
205 |
return 0.39 * (words / sentences_count) + 11.8 * (syllables / words) - 15.59
|
206 |
|
207 |
def flesch_reading_ease(text):
|
208 |
+
sentences, sentences_count = pre_process_text(text)
|
209 |
words = extract_words(sentences)
|
210 |
syllables = sum([count_syllables(word) for word in text.split()])
|
211 |
|
|
|
214 |
return 206.835 - 1.015 * (words / sentences_count) - 84.6 * (syllables / words)
|
215 |
|
216 |
def gunning_fog_index(text):
|
217 |
+
sentences, sentences_count = pre_process_text(text)
|
218 |
words = extract_words(sentences)
|
219 |
complex_words = len([word for word in text.split() if count_syllables(word) >= 3])
|
220 |
|
|
|
223 |
return 0.4 * ((words / sentences_count) + 100 * (complex_words / words))
|
224 |
|
225 |
def calculate_readability_metrics(text):
|
226 |
+
fk_grade_level = flesch_kincaid_grade_level(text)
|
227 |
+
fk_reading_ease = flesch_reading_ease(text)
|
228 |
+
gunning_fog = gunning_fog_index(text)
|
|
|
229 |
|
230 |
return fk_grade_level, fk_reading_ease, gunning_fog
|
231 |
#-------------#
|