umarigan commited on
Commit
418cafa
·
verified ·
1 Parent(s): e5e6aae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -15
app.py CHANGED
@@ -105,24 +105,11 @@ def create_mask_dict(entities):
105
  mask_dict[entity['word']] = f"{entity['entity_group']}_{entity_counters[entity['entity_group']]}"
106
  return mask_dict
107
 
108
- def create_masked_text(input_text, entities):
109
- mask_dict = create_mask_dict(entities)
110
-
111
- masked_text = input_text
112
- for entity in sorted(entities, key=lambda x: x['start'], reverse=True):
113
- if entity['entity_group'] not in ['CARDINAL', 'EVENT']:
114
- masked_text = (
115
- masked_text[:entity['start']] +
116
- f"<{mask_dict[entity['word']]}> " + # Use angle brackets for clarity
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
 
 
105
  mask_dict[entity['word']] = f"{entity['entity_group']}_{entity_counters[entity['entity_group']]}"
106
  return mask_dict
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  def replace_words_in_text(input_text, entities):
109
  replace_dict = create_mask_dict(entities)
110
  for word, replacement in replace_dict.items():
111
+ input_text = input_text.replace(word, replacement)
112
+ return input_text
113
 
114
  Run_Button = st.button("Run")
115