badwords
badwords copied to clipboard
No Substring Filter?
Hopefully I'm missing something or using the package incorrectly but seems like its not finding bad words as substrings..?
import Filter from 'bad-words';
const filter = new Filter();
console.log(filter.clean('xyz ass4ca')); // xyz ass4ca
console.log(filter.clean('xyz 555ass')); // xyz 555ass
console.log(filter.clean('xyz ass')); // xyz ***
Did you find a solution or another library that does this?
Bass. Assistant. Raccoon. Shitake mushrooms. Peacock.
B***. ***istant. Rac****. ****ake mushrooms. Pea****.
Is this really a good idea?
It would be nice to at least have the option, as certain racial slurs do not really fit into any other words like Shitake :)
people bypass the filter by doing adding an underscore on the word, or adding an extra r on the n word
ass_
+1 for adding the option to filter substrings. I'm creating a referral code generator that spits out a random alphanumeric code that the user can send to a friend to get them to sign up. We want to reduce the chances of offensive words sneaking into the randomly-generated string.
I'd love it if there was a way to force certain bad words from being filtered out, like the F word... how many times does the F word show up inside of other words?
Warning, the following contains language that may be found as offensive!
All of the above totally bypassed the isProfane function.
@dodocodes is correct in this regard, however, @brianreavis brings up https://www.wikiwand.com/en/Scunthorpe_problem There should be a way to enhance accuracy, e.g. detecting compound curses and ignoring special character padding.
Bass. Assistant. Raccoon. Shitake mushrooms. Peacock. B***. ***istant. Rac****. ****ake mushrooms. Pea****.
Is this really a good idea?
Fair point but for some use cases it can be desired, for example when we are generating random character serial numbers for item labels, we would like to filter any expletives that can be accidentally generated as as substring
Has anyone found a way to enable a substring filter? As mentioned above it is very useful in some use cases.
Bass. Assistant. Raccoon. Shitake mushrooms. Peacock. B***. ***istant. Rac****. ****ake mushrooms. Pea****.
Is this really a good idea?
Fair point but for some use cases it can be desired, for example when we are generating random character serial numbers for item labels, we would like to filter any expletives that can be accidentally generated as as substring
I agree that having the option to apply the filter for words containing bad words is desirable. The exclude list should be used to allow words like "raccoon" and "peacock" to pass without issue. Since developers can manage that list using the "removeWords" feature, it should be fairly straight-forward to implement this option without breaking changes.
people bypass the filter by doing adding an underscore on the word, or adding an extra r on the n word
ass_
use the following splitRegex to consider _ as a word boundary:
new Filter({splitRegex: /(?:(?=[a-zA-Z0-9]))(?<![a-zA-Z0-9])|(?<=[a-zA-Z0-9])(?![a-zA-Z0-9])/})
A slight thought: compound word bounds are good grounds for filtering, inherent words with coincidental substring is not. Problem: how do toy know it is not a prefix or suffix? the "B" in Bass is not a word. The "istant" in Assistant is not a word. The "Rac" in Raccoon is not a word. The "ake" in Shitake is not a word... BUT "Pea" is a word in Peacock. This is can be captured in secondary sense through wordlists.