jo3-l / obscenity

Robust, extensible profanity filter for NodeJS
MIT License
82 stars 5 forks source link

request: Censor the word "shit" #47

Closed HatScripts closed 11 months ago

HatScripts commented 11 months ago

Description

I was surprised to realize that this library doesn't censor the word "shit" by default, given that it's one of the most common English swear words.

Solution

I'm not fully versed with the pattern syntax used by this project, but here's my attempt at implementing it:

.addPhrase((phrase) => 
  phrase
    .setMetadata({ originalWord: 'shit' })
    .addPattern(pattern`shit`)
    .addWhitelistedTerm('s hit')
    .addWhitelistedTerm('sh it')
    .addWhitelistedTerm('shi t')
    .addWhitelistedTerm('shitake')
)

This should cover words where "shit-" is the prefix ("shitty", "shite", "shithead", etc.), as well as words where "-shit" is the suffix ("bullshit", "dipshit", "batshit", etc.)

Code of Conduct

jo3-l commented 11 months ago

Thanks, I included your patch verbatim (additionally whitelisting the word mishit) in version 0.2.0 of Obscenity.

HatScripts commented 11 months ago

Thanks for the update! There are also some alternative spellings of shit listed on its Wiktionary page: