File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,7 +11,10 @@ import (
1111
1212const Space = " "
1313
14- var defaultProfanityDetector * ProfanityDetector
14+ var (
15+ defaultProfanityDetector * ProfanityDetector
16+ removeAccentsTransformer transform.Transformer
17+ )
1518
1619// ProfanityDetector
1720type ProfanityDetector struct {
@@ -103,8 +106,10 @@ func (g ProfanityDetector) sanitize(s string) string {
103106}
104107
105108func removeAccents (s string ) string {
106- t := transform .Chain (norm .NFD , runes .Remove (runes .In (unicode .Mn )), norm .NFC )
107- output , _ , _ := transform .String (t , s )
109+ if removeAccentsTransformer == nil {
110+ removeAccentsTransformer = transform .Chain (norm .NFD , runes .Remove (runes .In (unicode .Mn )), norm .NFC )
111+ }
112+ output , _ , _ := transform .String (removeAccentsTransformer , s )
108113 return output
109114}
110115
You can’t perform that action at this time.
0 commit comments