Profanity detection and filtering library.
npm install swearjar-extended
{
categoryCount: {
sexual: 1
},
censored: '** you john doe',
profane: true,
wordCount: {
fuck: 1
},
words: {
fuck: [
'sexual'
]
}
}
`
$3
Generates a report from the given text.
swearjar.scorecard("fuck you john doe bitch fuck"); // {sexual: 2, insult: 1}
$3
Add a regex.
swearjar.addRegex('addedword?\\b', ['detected']);
$3
Add a simple word.
swearjar.addSimple('addedword', ['detected']);
$3
Add an emoji word.
swearjar.addEmoji('1f596', ['detected']);
$3
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.
`
{
"regex": {
"\\wfuck\\w": [
"category1",
"category2"
],
"word2": [
"category1"
],
"word3": [
"category2"
]
},
"simple": {
"word1": [
"category1",
"category2"
],
"word2": [
"category1"
],
"word3": [
"category2"
]
},
"emoji": {
"1f4a9": [
"category1",
"category2"
],
"word2": [
"category1"
],
"word3": [
"category2"
]
}
}
`
Acknowledgements
swearjar-node` is based on Swearjar (Ruby) and Swearjar PHP.