Skip to main content

wordfilter

A small module meant for use in text generators. It lets you filter strings for bad words.

Getting Started

Install the module with: npm install wordfilter

var wordfilter = require('wordfilter');
wordfilter.blacklisted('does this string have a bad word in it?'); // "false"

// clear the list entirely
wordfilter.clearList();

// add new words
wordfilter.addWords(['zebra','elephant']);
wordfilter.blacklisted('this string has zebra in it'); // "true"

// remove a word
wordfilter.removeWord('zebra');
wordfilter.blacklisted('this string has zebra in it'); // "false"

Or with Python: Install the module with: pip install wordfilter

from wordfilter import Wordfilter
wordfilter = Wordfilter()
wordfilter.blacklisted('does this string have a bad word in it?')  # False

# clear the list entirely
wordfilter.clearList()

# add new words
wordfilter.addWords(['zebra','elephant'])
wordfilter.blacklisted('this string has zebra in it')  # True

Documentation

This is a word filter adapted from code that I use in a lot of my twitter bots. It is based on a list of words that I've hand-picked for exclusion from my bots: essentially, it's a list of things that I would not say myself. Generally speaking, they are "words of oppression", aka racist/sexist/ableist things that I would not say.

The list is not all-inclusive, and I'm always adding words to it. If you'd like to file an issue or a pull request to add more words, please do so, but understand that this is primarily for use in my own projects, and I may not agree to add certain words. (For example, I have no problem with scatological words, so "shit" and "fuck" will never be on this list.)

Words are case insensitive.

Also note that due to the complexities of the English language, I am considering anything containing the substring of a bad word to be blacklisted. For example, even though "homogenous" is not a bad word, it contains the substring "homo" and it gets filtered. The reason for this is that new slang pops up all the time using compound words and I can't possibly keep up with it. I'm willing to lose a few words like "homogenous" and "Pakistan" in order to avoid false negatives.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

License

Copyright (c) 2013 Darius Kazemi Licensed under the MIT license.

Metadata

Release files for wordfilter 0.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wordfilter 0.2.7
File Size Uploaded
wordfilter-0.2.7.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wordfilter 0.2.7
File Interpreter ABI Platform
wordfilter-0.2.7-py3-none-any.whl Python 3 none any Details

Total release size: 8.8 kB

Release files / wordfilter-0.2.7.tar.gz

Download URL wordfilter-0.2.7.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
81b5d8077d1004d5a6fd56e02c506e93f49ef30920e235fa28ff7950a7b44c31
BLAKE2b-256 checksum
How to use checksums
40230674c5228f9f45079fa82821ec7861fb81c5d4943b73e2d58501595a9664
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.8

Release files / wordfilter-0.2.7-py3-none-any.whl

Download URL wordfilter-0.2.7-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bca1959109fed57051e2484dc2b47f1f8b1d3241eaa6ea50a6151d19f2466638
BLAKE2b-256 checksum
How to use checksums
ea695093450f36945ba1e06163a5cb3feb414468cf3fa25fb13ad6c06fa2064b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.8

Release history Release notifications | RSS feed

This release

0.2.7 This release

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.1.9

2 release files

0.1.8

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page