npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

swearjar-extended2

v0.2.9

Published

Profanity detection and filtering library.

Downloads

260

Readme

swearjar-extended2

This is a modified version of swearjar-extended

Profanity detection and filtering library.

Build Status

Installation

npm install --save swearjar-extended2

Usage

swearjar.setLang(text)

Sets a language to load a dictionary of words to be used as filter.

| Language | Code | | -------------------------------------------------------- | ----------------- | | English | en | | Filipino | ph | | Spanish | es | | Bahasa | id |

NOTE: A US English default list located in the config directory is included and loaded by default.

var swearjar = require('swearjar-extended2');
swearjar.setLang("en");

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"
    ]
  }
}

swearjar.profane(text)

Returns true if the given string contains profanity.

var swearjar = require('swearjar-extended2');
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']);

Acknowledgements

swearjar-node is based on Swearjar (Ruby) and Swearjar PHP.

Sources