saurabhg2083 commited on
Commit
8029781
1 Parent(s): 2423be8

update grammar issue

Browse files
Files changed (1) hide show
  1. app.py +22 -2
app.py CHANGED
@@ -219,10 +219,30 @@ if st.button("Check Bias"):
219
  #print(f"Predicted Label: {predicted_label_text}")
220
  if predicted_label_text == "Positive":
221
  rewritten_sentence = replace_gendered_pronouns(text1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  # Add the prefix "grammar: " before each input
223
- result = happy_tt.generate_text("grammar: "+rewritten_sentence, args=args)
224
  #print(result.text) # This sentence has bad grammar.
225
- st.success(f"Predicted Label: {predicted_label_text} and new Text is: {result.text}")
226
  else:
227
  st.warning("Please enter text Job Description.")
228
 
 
219
  #print(f"Predicted Label: {predicted_label_text}")
220
  if predicted_label_text == "Positive":
221
  rewritten_sentence = replace_gendered_pronouns(text1)
222
+ words = rewritten_sentence.split()
223
+ word_count = 0
224
+ chunk = ""
225
+ target_word_count = 35
226
+ result = ""
227
+
228
+ for word in words:
229
+ # Add the sentence to the current chunk
230
+ chunk += word + " "
231
+
232
+ words_list = chunk.split()
233
+ word_count = len(words_list)
234
+
235
+ # Check if the word count exceeds the target
236
+ if word_count >= target_word_count:
237
+ grammar_text = happy_tt.generate_text("grammar: "+chunk, args=args)
238
+ result = result + grammar_text.text
239
+ chunk = ""
240
+ word_count = 0
241
+
242
  # Add the prefix "grammar: " before each input
243
+ #result = happy_tt.generate_text("grammar: "+rewritten_sentence, args=args)
244
  #print(result.text) # This sentence has bad grammar.
245
+ st.success(f"Predicted Label: {predicted_label_text} \n new Text is: {result}")
246
  else:
247
  st.warning("Please enter text Job Description.")
248