forked from aliengiraffe/deidentify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
97 lines (82 loc) · 2.95 KB
/
main.go
File metadata and controls
97 lines (82 loc) · 2.95 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package main
import (
"fmt"
"log"
"github.com/aliengiraffe/deidentify"
)
func main() {
// Generate a secure secret key
secretKey, err := deidentify.GenerateSecretKey()
if err != nil {
log.Fatal("Failed to generate secret key:", err)
}
// Create a new deidentifier with default options
d := deidentify.NewDeidentifier(secretKey)
// Sample international addresses
addresses := []string{
"123 Main Street, Springfield, IL", // US
"10 Downing Street, London, UK", // UK
"1600 Pennsylvania Avenue, Washington DC", // US
"221B Baker Street, London, UK", // UK (famous)
"42 Rue de la Paix, Paris, France", // France
"1234 Calle Mayor, Madrid, Spain", // Spain
"56 Via Roma, Rome, Italy", // Italy
"789 Königstraße, Berlin, Germany", // Germany
"5-1-5 Ginza, Chuo-ku, Tokyo, Japan", // Japan
"888 Nanjing Road, Shanghai, China", // China
"27 Sheikh Zayed Road, Dubai, UAE", // UAE
"45 Sukhumvit Road, Bangkok, Thailand", // Thailand
"33 Nevsky Prospekt, St. Petersburg, Russia", // Russia
"17 Andrássy út, Budapest, Hungary", // Hungary
}
// Process and display
fmt.Println("International Address Detection and Deidentification")
fmt.Println("===================================================")
fmt.Println()
// Special focus on our problematic examples
fmt.Println("FOCUS ON SPECIFIC EXAMPLES:")
fmt.Println("---------------------------")
specificExamples := []string{
"123 Orchard Road, Singapore",
"15 Rue de Rivoli, Paris, France",
}
for _, address := range specificExamples {
redacted, err := d.Address(address)
if err != nil {
fmt.Printf("Error processing '%s': %v\n", address, err)
continue
}
fmt.Printf("Original: %s\n", address)
fmt.Printf("Redacted: %s\n\n", redacted)
}
fmt.Println("OTHER INTERNATIONAL EXAMPLES:")
fmt.Println("----------------------------")
for _, address := range addresses {
redacted, err := d.Address(address)
if err != nil {
fmt.Printf("Error processing '%s': %v\n", address, err)
continue
}
fmt.Printf("Original: %s\n", address)
fmt.Printf("Redacted: %s\n\n", redacted)
}
// Sample text with international addresses - focusing on the specific examples
text := `Our company has offices at multiple locations:
- European HQ: 15 Rue de Rivoli, Paris, France (this is our main office)
- Asian HQ: 123 Orchard Road, Singapore
- North American HQ: 555 Fifth Avenue, New York, NY
- Middle Eastern office: 78 Sheikh Zayed Road, Dubai, UAE
Please contact us at contact@example.com or call our main line at (555) 123-4567.`
// Process the text
fmt.Println("Text with International Addresses")
fmt.Println("================================")
fmt.Println("Original:")
fmt.Println(text)
fmt.Println()
redactedText, err := d.Text(text)
if err != nil {
log.Fatal("Failed to deidentify text:", err)
}
fmt.Println("Redacted:")
fmt.Println(redactedText)
}