rodrigomasini commited on
Commit
66cb9ef
·
verified ·
1 Parent(s): 426b454

Update app_v1.py

Browse files
Files changed (1) hide show
  1. app_v1.py +7 -1
app_v1.py CHANGED
@@ -269,6 +269,12 @@ def flesch_reading_ease(text):
269
  def gunning_fog_index(text):
270
  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)
@@ -276,7 +282,7 @@ def calculate_readability_metrics(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:
 
269
  def gunning_fog_index(text):
270
  sentences = pre_process_text(text)
271
  return textstat.gunning_fog(sentences)
272
+
273
+ def categorize_metrics(cont_clarity, fk_reading_ease, gunning_fog):
274
+ clarity_category = "Low" if cont_clarity <= 5 else "Normal" if cont_clarity <= 10 else "High"
275
+ understandability_category = "Low" if fk_reading_ease <= 29 else "Normal" if fk_reading_ease <= 69 else "High"
276
+ conciseness_category = "Low" if gunning_fog <= 6 else "Normal" if gunning_fog <= 12 else "High"
277
+ return clarity_category, understandability_category, conciseness_category
278
 
279
  def calculate_readability_metrics(text):
280
  #fk_grade_level = flesch_kincaid_grade_level(text)
 
282
  fk_reading_ease = flesch_reading_ease(text)
283
  gunning_fog = gunning_fog_index(text)
284
 
285
+ return categorize_metrics(cont_clarity, fk_reading_ease, gunning_fog)
286
  #-------------#
287
 
288
  with gr.Blocks(title="RecurrentGPT", css="footer {visibility: hidden}", theme='sudeepshouche/minimalist') as demo: