rodrigomasini commited on
Commit
87a07f1
·
verified ·
1 Parent(s): 8e833eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -1
app.py CHANGED
@@ -169,6 +169,16 @@ def on_select(instruction1, instruction2, instruction3, evt: gr.SelectData):
169
  selected_plan = [instruction1, instruction2, instruction3][selected_plan-1]
170
  return selected_plan
171
 
 
 
 
 
 
 
 
 
 
 
172
 
173
  with gr.Blocks(title="RecurrentGPT", css="footer {visibility: hidden}", theme='sudeepshouche/minimalist') as demo:
174
  gr.Markdown(
@@ -275,7 +285,21 @@ with gr.Blocks(title="RecurrentGPT", css="footer {visibility: hidden}", theme='s
275
  short_memory, long_memory, written_paras, instruction1, instruction2, instruction3])
276
  selected_plan.select(on_select, inputs=[
277
  instruction1, instruction2, instruction3], outputs=[selected_instruction])
278
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  demo.queue(concurrency_count=1)
280
 
281
  if __name__ == "__main__":
 
169
  selected_plan = [instruction1, instruction2, instruction3][selected_plan-1]
170
  return selected_plan
171
 
172
+ #----------------#
173
+ # Grammar metrics
174
+ import textstat
175
+
176
+ def calculate_metrics(text):
177
+ flesch_kincaid_grade = textstat.flesch_kincaid_grade(text)
178
+ flesch_reading_ease = textstat.flesch_reading_ease(text)
179
+ gunning_fog = textstat.gunning_fog(text)
180
+
181
+ return flesch_kincaid_grade, flesch_reading_ease, gunning_fog
182
 
183
  with gr.Blocks(title="RecurrentGPT", css="footer {visibility: hidden}", theme='sudeepshouche/minimalist') as demo:
184
  gr.Markdown(
 
285
  short_memory, long_memory, written_paras, instruction1, instruction2, instruction3])
286
  selected_plan.select(on_select, inputs=[
287
  instruction1, instruction2, instruction3], outputs=[selected_instruction])
288
+ with gr.Tab("Metrics"):
289
+ with gr.Row():
290
+ with gr.Column()
291
+ flesch_kincaid_grade = gr.Number(label="Flesch-Kincaid Grade Level")
292
+ flesch_reading_ease = gr.Number(label="Flesch Reading Ease")
293
+ gunning_fog = gr.Number(label="Gunning Fog Index")
294
+
295
+ calculate_button = gr.Button("Calculate Metrics")
296
+
297
+ def update_metrics(text):
298
+ grade, ease, fog = calculate_metrics(text)
299
+ return grade, ease, fog
300
+
301
+ calculate_button.click(fn=update_metrics, inputs=input_text, outputs=[flesch_kincaid_grade, flesch_reading_ease, gunning_fog])
302
+
303
  demo.queue(concurrency_count=1)
304
 
305
  if __name__ == "__main__":