-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
43 lines (31 loc) · 1.23 KB
/
test.py
File metadata and controls
43 lines (31 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# filename: test_presidio_en.py
from presidio_analyzer import AnalyzerEngine
from presidio_anonymizer import AnonymizerEngine
# --------------------------------------------------
# 1) Presidio 엔진 초기화
# --------------------------------------------------
analyzer = AnalyzerEngine()
anonymizer = AnonymizerEngine()
# --------------------------------------------------
# 2) 테스트 입력 텍스트 (영어)
# --------------------------------------------------
text = """
User John Doe's email is john.doe@example.com and his phone number is 415-555-2671.
The temporary password is qsd123! and credit card number is 4111-1111-1111-1111.
"""
# --------------------------------------------------
# 3) Presidio 분석 수행
# --------------------------------------------------
results = analyzer.analyze(text=text, language="en")
print("\n===== [1] 분석 결과 =====")
for r in results:
print(f"{r.entity_type} ({r.start}-{r.end}) score={r.score:.2f}")
# --------------------------------------------------
# 4) Presidio 마스킹 수행
# --------------------------------------------------
anonymized = anonymizer.anonymize(
text=text,
analyzer_results=results
)
print("\n===== [2] 마스킹 결과 =====")
print(anonymized.text)