Spaces:
Build error
Build error
Upload 4 files
Browse files
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title: 민감정보마스킹[
|
3 |
emoji: 🛡️
|
4 |
colorFrom: blue
|
5 |
colorTo: indigo
|
|
|
1 |
---
|
2 |
+
title: 민감정보마스킹 [땡땡이 마스킹]
|
3 |
emoji: 🛡️
|
4 |
colorFrom: blue
|
5 |
colorTo: indigo
|
app.py
CHANGED
@@ -1,4 +1,29 @@
|
|
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import gradio as gr
|
3 |
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
|
4 |
import re
|
@@ -61,14 +86,6 @@ def to_chosung(text):
|
|
61 |
result += ch
|
62 |
return result
|
63 |
|
64 |
-
def mask_school_names(text):
|
65 |
-
school_patterns = [
|
66 |
-
(r"(\b[가-힣]{2,20})(초등학교|중학교|고등학교)", True),
|
67 |
-
(r"(\b[가-힣]{2,20})\s(초등학교|중학교|고등학교)", False),
|
68 |
-
]
|
69 |
-
for pattern, attach in school_patterns:
|
70 |
-
text = re.sub(pattern, lambda m: to_chosung(m.group(1)) + (" " if not attach else "") + m.group(2), text)
|
71 |
-
return text
|
72 |
|
73 |
|
74 |
def mask_department(text):
|
@@ -126,7 +143,12 @@ def remask_with_mapping(text, mapping_string):
|
|
126 |
return text
|
127 |
|
128 |
with gr.Blocks() as demo:
|
129 |
-
gr.Markdown("
|
|
|
|
|
|
|
|
|
|
|
130 |
input_text = gr.Textbox(lines=15, label="📥 원본 텍스트 입력")
|
131 |
keyword_input = gr.Textbox(lines=1, label="기관 키워드 (쉼표로 구분)", value="굿네이버스, good neighbors, gn, 사회복지법인 굿네이버스")
|
132 |
replace_input = gr.Textbox(lines=1, label="치환할 텍스트", value="우리기관")
|
|
|
1 |
|
2 |
+
school_name_candidates = []
|
3 |
+
|
4 |
+
def mask_school_names(text):
|
5 |
+
global school_name_candidates
|
6 |
+
school_name_candidates = []
|
7 |
+
|
8 |
+
def replacer(match):
|
9 |
+
name = match.group(1)
|
10 |
+
full = match.group(0)
|
11 |
+
if 2 <= len(name) <= 20:
|
12 |
+
school_name_candidates.append(name)
|
13 |
+
return to_chosung(name) + match.group(2)
|
14 |
+
else:
|
15 |
+
return full
|
16 |
+
|
17 |
+
# 붙어 있는 학교명 (수원매화초등학교)
|
18 |
+
text = re.sub(r"(\b[가-힣]{2,20})(초등학교|중학교|고등학교)", replacer, text)
|
19 |
+
|
20 |
+
# 후처리: 띄어쓰기 있는 패턴 (수원 매화 초등학교 등)
|
21 |
+
for name in school_name_candidates:
|
22 |
+
pattern = rf"{re.escape(name)}\s?(초등학교|중학교|고등학교)"
|
23 |
+
text = re.sub(pattern, to_chosung(name) + " " + r"\1", text)
|
24 |
+
return text
|
25 |
+
|
26 |
+
|
27 |
import gradio as gr
|
28 |
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
|
29 |
import re
|
|
|
86 |
result += ch
|
87 |
return result
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
|
91 |
def mask_department(text):
|
|
|
143 |
return text
|
144 |
|
145 |
with gr.Blocks() as demo:
|
146 |
+
gr.Markdown("""
|
147 |
+
🛡️ **민감정보 마스킹 [땡땡이 마스킹]**
|
148 |
+
이름 + 민감정보 + 초/중/고 마스킹기 (초성 기반)
|
149 |
+
|
150 |
+
⚠️ *완벽하지 않을 수 있습니다. 반드시 직접 최종 점검하세요.*
|
151 |
+
""")
|
152 |
input_text = gr.Textbox(lines=15, label="📥 원본 텍스트 입력")
|
153 |
keyword_input = gr.Textbox(lines=1, label="기관 키워드 (쉼표로 구분)", value="굿네이버스, good neighbors, gn, 사회복지법인 굿네이버스")
|
154 |
replace_input = gr.Textbox(lines=1, label="치환할 텍스트", value="우리기관")
|