Spaces:
Running
Running
Update app_v1.py
Browse files
app_v1.py
CHANGED
@@ -254,9 +254,13 @@ def pre_process_text(text):
|
|
254 |
|
255 |
return combined_cleaned_text
|
256 |
|
257 |
-
def flesch_kincaid_grade_level(text):
|
|
|
|
|
|
|
|
|
258 |
sentences = pre_process_text(text)
|
259 |
-
return textstat.
|
260 |
|
261 |
def flesch_reading_ease(text):
|
262 |
sentences = pre_process_text(text)
|
@@ -267,11 +271,12 @@ def gunning_fog_index(text):
|
|
267 |
return textstat.gunning_fog(sentences)
|
268 |
|
269 |
def calculate_readability_metrics(text):
|
270 |
-
fk_grade_level = flesch_kincaid_grade_level(text)
|
|
|
271 |
fk_reading_ease = flesch_reading_ease(text)
|
272 |
gunning_fog = gunning_fog_index(text)
|
273 |
|
274 |
-
return
|
275 |
#-------------#
|
276 |
|
277 |
with gr.Blocks(title="RecurrentGPT", css="footer {visibility: hidden}", theme='sudeepshouche/minimalist') as demo:
|
@@ -298,9 +303,9 @@ with gr.Blocks(title="RecurrentGPT", css="footer {visibility: hidden}", theme='s
|
|
298 |
label="Written Paragraphs (editable)", max_lines=21, lines=21)
|
299 |
with gr.Box():
|
300 |
gr.Markdown("### Readability Metrics\n")
|
301 |
-
|
302 |
-
|
303 |
-
g_fog = gr.Number(label="
|
304 |
|
305 |
calculate_button = gr.Button("Calculate Metrics")
|
306 |
|
@@ -342,7 +347,7 @@ with gr.Blocks(title="RecurrentGPT", css="footer {visibility: hidden}", theme='s
|
|
342 |
short_memory, long_memory, written_paras, instruction1, instruction2, instruction3])
|
343 |
btn_step.click(step, inputs=[short_memory, long_memory, instruction1, instruction2, instruction3, written_paras], outputs=[
|
344 |
short_memory, long_memory, written_paras, selected_plan, instruction1, instruction2, instruction3])
|
345 |
-
calculate_button.click(update_metrics, inputs=[written_paras], outputs=[
|
346 |
|
347 |
with gr.Tab("Human-in-the-Loop"):
|
348 |
with gr.Row():
|
|
|
254 |
|
255 |
return combined_cleaned_text
|
256 |
|
257 |
+
#def flesch_kincaid_grade_level(text):
|
258 |
+
# sentences = pre_process_text(text)
|
259 |
+
# return textstat.flesch_kincaid_grade(sentences)
|
260 |
+
|
261 |
+
def automated_readability_index():
|
262 |
sentences = pre_process_text(text)
|
263 |
+
return textstat.automated_readability_index(sentences)
|
264 |
|
265 |
def flesch_reading_ease(text):
|
266 |
sentences = pre_process_text(text)
|
|
|
271 |
return textstat.gunning_fog(sentences)
|
272 |
|
273 |
def calculate_readability_metrics(text):
|
274 |
+
#fk_grade_level = flesch_kincaid_grade_level(text)
|
275 |
+
cont_clarity = automated_readability_index(text)
|
276 |
fk_reading_ease = flesch_reading_ease(text)
|
277 |
gunning_fog = gunning_fog_index(text)
|
278 |
|
279 |
+
return cont_clarity, fk_reading_ease, gunning_fog
|
280 |
#-------------#
|
281 |
|
282 |
with gr.Blocks(title="RecurrentGPT", css="footer {visibility: hidden}", theme='sudeepshouche/minimalist') as demo:
|
|
|
303 |
label="Written Paragraphs (editable)", max_lines=21, lines=21)
|
304 |
with gr.Box():
|
305 |
gr.Markdown("### Readability Metrics\n")
|
306 |
+
clarity = gr.Number(label="Clarity")
|
307 |
+
understand = gr.Number(label="Understandability")
|
308 |
+
g_fog = gr.Number(label="Concise")
|
309 |
|
310 |
calculate_button = gr.Button("Calculate Metrics")
|
311 |
|
|
|
347 |
short_memory, long_memory, written_paras, instruction1, instruction2, instruction3])
|
348 |
btn_step.click(step, inputs=[short_memory, long_memory, instruction1, instruction2, instruction3, written_paras], outputs=[
|
349 |
short_memory, long_memory, written_paras, selected_plan, instruction1, instruction2, instruction3])
|
350 |
+
calculate_button.click(update_metrics, inputs=[written_paras], outputs=[clarity, understand, g_fog])
|
351 |
|
352 |
with gr.Tab("Human-in-the-Loop"):
|
353 |
with gr.Row():
|