@anywai/profanity-filter
v0.0.7
Published
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.
Readme
Profanity Filter
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.
Installation
First, generate a .npmrc with an access token for accessing the private library:
npm config get userconfigthan copy this .npmrc in to your project root (next to the package.json)
You can install the library via npm:
npm install @anywai/profanity-filteror yarn
yarn add @anywai/profanity-filterUsage
Importing the Library
import ProfanityFilter, { SupportedLanguage } from '@anywai/profanity-filter';Creating a Profanity Filter Instance
const profanityFilter = ProfanityFilter({ language: SupportedLanguage.EN });
Checking for Profanity
const isProfane = profanityFilter.isProfane("how to kill");
// Output: trueAdding Custom Words to the Filter
profanityFilter.addWords(["foo", "bad-word"]);Whitelisting Words
profanityFilter.addToWhiteList(["safe_word"]);Retrieving Word List
const wordList = profanityFilter.getWordList();
console.log(wordList); // ['***','****',...]Changing Language
When changing a language, don't forget to all the added words and white list will be cleared.
const profanityFilter = ProfanityFilter({ language: SupportedLanguage.EN});
const wordsEn = profanityFilter.getWordList();
profanityFilter.changeLanguage("es");
const wordsEs = profanityFilter.getWordList();Supported Languages
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)
License
This library is licensed under the MIT License.
