umarigan commited on
Commit
6f7c1fb
·
verified ·
1 Parent(s): 0cb91b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -117,6 +117,12 @@ def create_masked_text(input_text, entities):
117
  masked_text[entity['end']:]
118
  )
119
  return masked_text
 
 
 
 
 
 
120
 
121
  Run_Button = st.button("Run")
122
 
@@ -144,7 +150,7 @@ if Run_Button and input_text:
144
  output_comb = entity_comb(all_outputs)
145
 
146
  # Create masked text and masking dictionary
147
- masked_text = create_masked_text(input_text, output_comb)
148
  mask_dict = create_mask_dict(output_comb)
149
 
150
  # Display the masked text and masking dictionary
 
117
  masked_text[entity['end']:]
118
  )
119
  return masked_text
120
+
121
+ def replace_words_in_text(input_text, entities):
122
+ replace_dict = create_mask_dict(entities)
123
+ for word, replacement in replace_dict.items():
124
+ text = text.replace(word, replacement)
125
+ return text
126
 
127
  Run_Button = st.button("Run")
128
 
 
150
  output_comb = entity_comb(all_outputs)
151
 
152
  # Create masked text and masking dictionary
153
+ masked_text = replace_words_in_text(input_text, output_comb)#create_masked_text(input_text, output_comb)
154
  mask_dict = create_mask_dict(output_comb)
155
 
156
  # Display the masked text and masking dictionary