0.0.9 • Published 9 months ago
wtf-wordfilter v0.0.9
What The Filter
A lightweight profanity detection tool.
How it works:
- Detects profanity and slurs in standard text, and hidden through the use of "l33tspeak" and character separation.
- badword
- b4dw0rd
- .b.4.d.w.0.r.d.
How to use it:
- Install the package by typing the following command into the terminal:
npm i wtf-wordfilter
- Import the package by adding the following line to the top of your file:
const { detectProfanity } = require("wtf-wordfilter");
- Use the filter by adding the string you want to test as a parameter:
// Returns true if string contains profanity, otherwise false.
const result = detectProfanity("badword");
console.log(result) // true
- That's it!
Caveats:
No filter is perfect. Adding more bad words to the filter will trigger it to catch more clean words. The pre-added words being filtered against are ones that are most likely to cause harm to a site. This maintains a good balance between the removal of bad words while keeping the majority of clean words.