aboutsummaryrefslogtreecommitdiff
path: root/pkg/names/gender.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/names/gender.go')
-rw-r--r--pkg/names/gender.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/pkg/names/gender.go b/pkg/names/gender.go
index bdd16e1..4282d9d 100644
--- a/pkg/names/gender.go
+++ b/pkg/names/gender.go
@@ -8,7 +8,7 @@ import (
func normalizeTitle(x string) string {
x = strings.ToLower(x)
- // strip common punctuation
+ // strip punctuation
x = strings.ReplaceAll(x, ".", "")
x = strings.ReplaceAll(x, "'", "")
x = strings.ReplaceAll(x, "’", "")
@@ -20,7 +20,6 @@ func GenderFromTitle(s string) model.Sex {
if s == "" {
return model.SexUnknown
}
- // only first token (before space/comma/slash/etc.)
cut := func(r rune) bool { return unicode.IsSpace(r) || r == ',' || r == '/' || r == '&' }
first := strings.FieldsFunc(s, cut)
if len(first) == 0 {
@@ -28,20 +27,19 @@ func GenderFromTitle(s string) model.Sex {
}
t := normalizeTitle(first[0])
- // male honorifics
+ // male
switch t {
- case "mr", "sir", "lord", "monsieur", "m", "don", "senor", "sr": // "sr" may collide with "senior"; context needed
+ case "mr", "sir", "lord", "monsieur", "m", "don", "senor", "sr":
return model.SexMale
}
- // female honorifics
+ // female
switch t {
case "mrs", "miss", "ms", "madam", "madame", "mademoiselle", "mlle",
"lady", "dame", "senora", "sra", "señora", "srta", "srita", "dona":
return model.SexFemale
}
- // neutral/ambiguous titles (return Unknown)
- // e.g., "mx", "dr", "prof", "rev", "coach", "officer", etc.
+ // flying helicopter
return model.SexUnknown
}