Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,20 @@ import re
|
|
3 |
import gradio as gr
|
4 |
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
# =============================================
|
7 |
# Configurable Constants
|
8 |
# =============================================
|
|
|
3 |
import gradio as gr
|
4 |
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
|
5 |
|
6 |
+
def sanitize_sensitive_info(text, keyword_string, replace_word):
|
7 |
+
# 📍 기관 키워드 치환
|
8 |
+
keywords = [k.strip() for k in keyword_string.split(",") if k.strip()]
|
9 |
+
for kw in keywords:
|
10 |
+
pattern = rf"{re.escape(kw)}(?=\W|$)"
|
11 |
+
text = re.sub(pattern, replace_word, text, flags=re.IGNORECASE)
|
12 |
+
|
13 |
+
# 📍 기본 민감정보 마스킹 예시 (이메일 앞부분 마스킹)
|
14 |
+
text = re.sub(r"\b[\w\.-]+@", "******@", text)
|
15 |
+
|
16 |
+
return text
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
# =============================================
|
21 |
# Configurable Constants
|
22 |
# =============================================
|