Spaces:
Build error
Build error
File size: 1,049 Bytes
8d71e5b 1ae49b6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import gradio as gr
import textstat
import pandas as pd
def do_action(document):
all_data = []
for paragraph in document.split("\n"):
if len(paragraph.split(" ")) < 10:
continue
data = {}
data['Flesch Kincaid'] = textstat.flesch_kincaid_grade(paragraph)
data['Linsear'] = textstat.linsear_write_formula(paragraph)
data['text'] = paragraph[:50]
# for score_name in scores:
# data[score_name] = getattr(textstat, score_name)(paragraph)
all_data.append(data)
overall_score = textstat.flesch_kincaid_grade(document)
return f"# Overall: {overall_score}", pd.DataFrame(all_data) \
.style.format(precision=2) \
.background_gradient('YlGnBu', vmin=8, vmax=15)
document = gr.Textbox(lines=40)
output_scores = gr.DataFrame(label="", wrap=False)
title = "Reading level score"
desc = """
"""
demo = gr.Interface(fn=do_action, title=title, description=desc, inputs=document, outputs=["markdown", output_scores])
demo.launch() |