This library provides a simple yet powerful profanity filtering mechanism for Node.js applications. It allows users to easily check for profane language in strings and manipulate the word lists used for filtering.
npm install @anywai/profanity-filterThis library provides a simple yet powerful profanity filtering mechanism for Node.js applications. It allows users to easily check for profane language in strings and manipulate the word lists used for filtering.
First, generate a .npmrc with an access token for accessing the private library:
``bash`
npm config get userconfig
than copy this .npmrc in to your project root (next to the package.json)
You can install the library via npm:
`bash`
npm install @anywai/profanity-filter
or yarn
`bash`
yarn add @anywai/profanity-filter
`js`
import ProfanityFilter, { SupportedLanguage } from '@anywai/profanity-filter';
`js
const profanityFilter = ProfanityFilter({ language: SupportedLanguage.EN });
`
`js`
const isProfane = profanityFilter.isProfane("how to kill");
// Output: true
`js`
profanityFilter.addWords(["foo", "bad-word"]);
`js`
profanityFilter.addToWhiteList(["safe_word"]);
`js
const wordList = profanityFilter.getWordList();
console.log(wordList); // ['','*',...]
`
When changing a language, don't forget to all the added words and white list will be cleared.
`js
const profanityFilter = ProfanityFilter({ language: SupportedLanguage.EN});
const wordsEn = profanityFilter.getWordList();
profanityFilter.changeLanguage("es");
const wordsEs = profanityFilter.getWordList();
``
The library supports the following languages:
- Arabic (ar)
- Danish (da)
- German (de)
- English (en)
- Esperanto (eo)
- Spanish (es)
- Persian (fa)
- Finnish (fi)
- Filipino (fil)
- French (fr)
- Hindi (hi)
- Hungarian (hu)
- Italian (it)
- Kabyle (kab)
- Japanese (ja)
- Korean (ko)
- Dutch (nl)
- Norwegian (no)
- Polish (pl)
- Portuguese (pt)
- Russian (ru)
- Swedish (sv)
- Thai (th)
- Klingon (tlh)
- Turkish (tr)
- Chinese (zh)
This library is licensed under the MIT License.