Make ignored characters configurable #24
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "remove-special-characters"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I added the ability to configure the special characters to be replaced. I also changed the implementation to be a loop over the string. Let me know if you disagree with this.
The mapping could also be implemented as
map[string]stringhowever this would complicate things with remembering the indexes. Currently there is only the case of()that has special handling.Codecov Report
100.00% <100.00%> (ø)100.00% <100.00%> (ø)Continue to review full report at Codecov.
@ -0,0 +1,26 @@package goawayDoes it really make sense to name them replacements, given that they're technically skipped/ignored/trimmed?
@ -0,0 +1,26 @@package goawaygood catch. I renamed and removed unnecessary variable
@ -43,6 +45,8 @@ func NewProfanityDetector() *ProfanityDetector {profanities: DefaultProfanities,Can you rename
specialCharactersReplacementMaptoignoredCharactersandDefaultIgnoredSpecialCharacterstoDefaultIgnoredCharacters?WithSpecialCharactersshould also be renamed toWithIgnoredCharacters, and the README should also be updated to reflect the new feature 😅@ -43,6 +45,8 @@ func NewProfanityDetector() *ProfanityDetector {profanities: DefaultProfanities,@martinhrvn I see you re-requested my review, but despite 👍ing my comment, but you didn't push any changes 😅
@ -43,6 +45,8 @@ func NewProfanityDetector() *ProfanityDetector {profanities: DefaultProfanities,@TwiN it must've got stuck in a pipe somewhere 🤦 I pushed now
@ -65,6 +65,13 @@ falseNegatives := []string{"dumbass"}profanityDetector := goaway.NewProfanityDetector().WithCustomDictionary(profanities, falsePositives, falseNegatives)Awesome work @martinhrvn! Thank you for the contribution :)
FYI, I merged
ignoredCharactersandleetSpeakReplacementMapinto one. See803cf25f73I was actually thinking about that and I think it makes sense to do.
Awesome :p
I just released the feature in v1.6.0
I was just thinking in that case we could probably get rid of the boolean configs for special characters and leet speak, since we could just set the appropriate replacements and use those. It would simplify the logic of the sanitization.. I will create PR and let you decide how you feel about that
Yeah but that's a breaking change, and I'm not too keen on making a breaking change at the moment