feat: implement WithExactWord to allow stricter matches #107
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "master"
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?
Summary
This is a fix for #38 to filter only exact words.
I chose to implement it by having an alternate implementation only for the profanities list, where the rest is untouched so false positives and false negatives will remain working as expected; it seems right to me that a false negative should not change from exact word matches.
I have one test in here. I could see a use for more, but comments/feedback in that area would be appreciated so I can calibrate what sort of test coverage you're aiming for.
Checklist
README.md, if applicable.@ -548,6 +548,36 @@ func TestFalsePositives(t *testing.T) {}Go uses camelCase instead of snake_case - could you make the changes to the other parts of your code?
@ -564,6 +594,10 @@ func TestFalseNegatives(t *testing.T) {name: "With Custom Dictionary",Was this a typo? It's a duplicate of the scenario above
thank you for the feedback @TwiN ! I've updated the PR with it. sorry it took a while—shortly after the feedback I went on holiday, but I should be able to have more timely iteration now if this needs any further work.
@ -548,6 +548,36 @@ func TestFalsePositives(t *testing.T) {}done in bf6efc8, thank you! the perils of switching between languages and getting my styles mixed up 😅
@ -564,6 +594,10 @@ func TestFalseNegatives(t *testing.T) {name: "With Custom Dictionary",yes, I meant to have it include coverage of the new code by setting it to use exact words for one of them. pushed that fix in bf6efc8
@ -129,15 +142,34 @@ func (g *ProfanityDetector) ExtractProfanity(s string) string {for _, word := range g.falsePositives {This may sound odd, but could you swap the blocks and make this if g.exactWord instead of if !g.exactWord? I feel it makes more sense
@ -129,15 +142,34 @@ func (g *ProfanityDetector) ExtractProfanity(s string) string {for _, word := range g.falsePositives {Yeah, sure! Done in 1ebc004. I agree that that's better, easier to reason about without a negation in the first case.
@TwiN Sorry for the delays on this! Life has been... rough. I made the requested change, and also rebased onto
TwiN:master.Hey folks, is there anything I can help with to get this merged? 💐
I think we’re just waiting for @TwiN to approve and merge (or request further changes)
Can you update the README.md
Once you've updated the README, I'll merge.
@TwiN done, thanks!
Can you please merge this @TwiN? 💐
I'll make a release in 30ish minutes, not home at the moment. Thank you for your patience folks :)
thank you so much, @TwiN !