New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

swearjar-extended

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swearjar-extended

Profanity detection and filtering library.

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
120
increased by0.84%
Maintainers
1
Weekly downloads
 
Created
Source

swearjar-extended

Profanity detection and filtering library.

Build Status

Installation

npm install --save swearjar-extended

Usage

swearjar.profane(text)

Returns true if the given string contains profanity.

var swearjar = require('swearjar-extended');
swearjar.profane("hello there"); // false
swearjar.profane("fuck you john doe"); // true

swearjar.censor(text)

Replaces profanity with asterisks.

var clean = swearjar.censor("fuck you john doe bitch"); // **** you john doe *****

swearjar.words(text)

Get the words alongside there categories.

swearjar.words('fuck you john doe'); // { fuck: ['sexual'] }

swearjar.detailedProfane(text)

Get the words alongside there categories, count and censor the text.

swearjar.detailedProfane('fuck you john doe')

returns:

{
  categoryCount: {
    sexual: 1
  },
  censored: '**** you john doe',
  profane: true,
  wordCount: {
    fuck: 1
  },
  words: {
    fuck: [
      'sexual'
    ]
  }
}

swearjar.scorecard(text)

Generates a report from the given text.

swearjar.scorecard("fuck you john doe bitch fuck"); // {sexual: 2, insult: 1}

swearjar.addRegex(text)

Add a regex.

swearjar.addRegex('addedword?\\b', ['detected']);

swearjar.addSimple(text)

Add a simple word.

swearjar.addSimple('addedword', ['detected']);

swearjar.addEmoji(text)

Add an emoji word.

swearjar.addEmoji('1f596', ['detected']);

swearjar.loadBadWords(path) nodeOnly

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": {
    "\\w*fuck\\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.

Contributors

Keywords

FAQs

Package last updated on 14 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc