Skip to content

Commit a470540

Browse files
committed
타입별 필터링 추가
1 parent 9159a84 commit a470540

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

main.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,17 @@ def mask_text(text: str, mask_char: str = "0") -> str:
193193
def filter_sensitive_info(text: str, fix_spelling: bool = False) -> Dict[str, Any]:
194194
"""민감 정보 필터링 (000으로 마스킹) + 오타 교정"""
195195

196+
# 기본 마스킹 매핑 설정
197+
if mask_mapping is None:
198+
mask_mapping = {
199+
"이름": "*",
200+
"지명": "#",
201+
"조직명": "@",
202+
"전화번호": "0",
203+
"이메일": "X",
204+
"default": "0" # 기본값
205+
}
206+
196207
# 1. 오타 교정 (옵션)
197208
spelling_result = None
198209
corrected_text = None
@@ -278,13 +289,15 @@ def filter_sensitive_info(text: str, fix_spelling: bool = False) -> Dict[str, An
278289
original_text = filtered_text[start:end]
279290

280291
# 000으로 마스킹
281-
masked = mask_text(original_text)
292+
mask_char = mask_mapping.get(entity['type'], mask_mapping['default'])
293+
masked = mask_text(original_text, mask_char)
282294
filtered_text = filtered_text[:start] + masked + filtered_text[end:]
283295

284296
result = {
285297
"original_text": text,
286298
"filtered_text": filtered_text,
287-
"detected_entities": sorted(unique_entities, key=lambda x: x['start'])
299+
"detected_entities": sorted(unique_entities, key=lambda x: x['start']),
300+
"mask_mapping_used": mask_mapping
288301
}
289302

290303
# 오타 교정 결과 추가

0 commit comments

Comments
 (0)