Created
April 5, 2022 16:03
-
-
Save wrandowR/5e90df8d2a9853e8786349f758f640b4 to your computer and use it in GitHub Desktop.
Revisions
-
W'w created this gist
Apr 5, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ func Normalize(text string) string { rgTable := rangetable.Merge(unicode.Mn, unicode.P) t := transform.Chain(norm.NFD, runes.Remove(runes.In(rgTable)), norm.NFC) text, _, err := transform.String(t, text) if err != nil { log.WithError(err).Error("Error normalizing text") return internalNormalize(text) } return internalNormalize(text) } func internalNormalize(text string) string { text = strings.TrimSpace(text) text = strings.ToLower(text) return text }