blueradiance commited on
Commit
0353945
·
verified ·
1 Parent(s): 8a34feb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -215,8 +215,20 @@ def sanitize_sensitive_info(text, keyword_string, replace_word):
215
 
216
  # 🔹 마스킹 함수 (정리된 최종본)
217
  def extract_names(text):
218
- # 이름이 '홍길동'이면 테스트용으로 감지
219
- return ["홍길동"] if "홍길동" in text else []
 
 
 
 
 
 
 
 
 
 
 
 
220
 
221
  def refactored_mask_names(text, names):
222
  counter = 1
 
215
 
216
  # 🔹 마스킹 함수 (정리된 최종본)
217
  def extract_names(text):
218
+ try:
219
+ results = ner_pipeline(text)
220
+ except Exception as e:
221
+ print("NER 오류 발생:", e)
222
+ return []
223
+
224
+ names = []
225
+ for entity in results:
226
+ if entity.get("entity_group") == "PS":
227
+ name = entity["word"].replace("##", "").strip()
228
+ if len(name) >= 2 and name not in NAME_ENTITY_EXCEPTIONS:
229
+ names.append(name)
230
+ return names
231
+
232
 
233
  def refactored_mask_names(text, names):
234
  counter = 1