https://github.com/raymondjavaxx/swearjar-node
Profanity detection and filtering library.
https://github.com/raymondjavaxx/swearjar-node
filtering-library javascript profanity profanity-detection
Last synced: 2 months ago
JSON representation
Profanity detection and filtering library.
- Host: GitHub
- URL: https://github.com/raymondjavaxx/swearjar-node
- Owner: raymondjavaxx
- License: mit
- Created: 2014-04-20T18:15:17.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2019-04-10T22:59:22.000Z (about 6 years ago)
- Last Synced: 2025-03-13T17:11:54.230Z (2 months ago)
- Topics: filtering-library, javascript, profanity, profanity-detection
- Language: JavaScript
- Size: 11.7 KB
- Stars: 74
- Watchers: 6
- Forks: 32
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# swearjar-node
Profanity detection and filtering library.
[](https://travis-ci.org/raymondjavaxx/swearjar-node)
## Installation
npm install --save swearjar
## Usage
### swearjar.profane(text)
Returns true if the given string contains profanity.
var swearjar = require('swearjar');
swearjar.profane("hello there"); // false
swearjar.profane("hello mother f-bomb"); // true### swearjar.censor(text)
Replaces profanity with asterisks.
var clean = swearjar.censor("f-bomb you"); // **** you
### swearjar.scorecard(text)
Generates a report from the given text.
swearjar.scorecard("f-bomb you"); // {sexual: 1, inappropriate: 1}
### swearjar.loadBadWords(path)
Loads a dictionary of words to be used as filter.
NOTE: A US English default list located in the config directory is included and loaded by default.
swearjar.loadBadWords('./config/profanity.json');
A dictionary is just a plain JSON file containing an object where its keys are the words to check for and the values are arrays of categories where the words fall in.
{
"word1": ["category1", "category2"],
"word2": ["category1"],
"word3": ["category2"]
}## Acknowledgements
`swearjar-node` is based on [Swearjar](https://github.com/joshbuddy/swearjar) (Ruby) and [Swearjar PHP](https://github.com/raymondjavaxx/swearjar-php).