Skip to main content

PyPI version Supported Python versions CircleCI

Red Flagger Word Catcher 🙅🚩

A simple, dependency-free software that does keyword-based abuse flagging. It is designed with a philosophy of sensitivity and a focus on recall rather than precision. It detects from a term list that contain terms that are discovered through lexicons and corpora containing hate speech, chatbot system abuse, toxicity, violence, and/or general profinity/obscenity.

🚨🚨 Important Note on Keyword Detection Systems 🚨🚨

We highly discourage the use of keyword systems as the only line of defense for toxicity and/or abuse detection. Problems associated with keyword detection systems range from performance issues to socially harmful false positives in cases like reclaimation. This system is encouraged to be used in conjunction with a review process and/or a stronger classification systems such as a deep learning model.

Examples of suggested, more robust use cases:

  • Keyword detection as part of an ensemble.
  • Keyword detection -> Deep learning classification on positives (Useful when there's a lot of data and not a lot of compute).
  • Using detected keywords as BOW features and then training classical models on said features.

For performance, see evaluation/.

Usage 🔨

For basic usage, all you have to do is:

$ pip install rfwc

from rfwc import RedFlagger

rf = RedFlagger()
document = "Something hateful"
hate_words = rf.detect_abuse(document)

There's also a method to get a bag-of-words from the wordlist:

...

hate_bow = rf.get_abuse_vector(document)

The library is designed to work with other word lists that are not built-in to the library. This can be managed with the add_words and remove_words methods. To get the current word list, there is the get_wordlist method.

Directory 📁

  • abuse_flagger/ contains the package code and the main logic.
  • data_building/ contains the code and documentation of how the initial dataset was created.
  • evaluation/ contains the evaluation of the keyword system on the test splits of the corpora used to discover the keywords.

Dataset Obscurity 😶‍🌫️

The word list is obscured as a base16 representation of the list of hate words. We did not feel comfortable exposing this list and we discourage any non-base16 representations of the wordlist being uploaded elsewhere. For details on dataset creation, see README.md in data_building/.

Other Resouces 📚

We acknowledge that there are other great resources and link some of them below:

Contributions 🤝

We welcome contributions for both the word list and the software using a fork-and-pull model. For additions to the word list, please ensure there are no duplicates or overlaps and that the additional data is obscured in base16. For any new features for the RedFlagger, open an issue for discussion first before opening a pull request.

Metadata

Release files for rfwc 0.1.2

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

Source distribution (sdist)

Source distribution for rfwc 0.1.2
File Size Uploaded
rfwc-0.1.2.tar.gz 34.2 kB Details

Built distribution (wheel)

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

Total release size: 67.6 kB

Release files / rfwc-0.1.2.tar.gz

Download URL rfwc-0.1.2.tar.gz
Size 34.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2b66c6fb4ecadd49070a7683852626ac98dbcf62ab8b585fe10826203a03b0bd
BLAKE2b-256 checksum
How to use checksums
1c6da0f242dfe25155f02806913083f3608dc5ad44a266b5ce12838fdc9b7fe8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release files / rfwc-0.1.2-py3-none-any.whl

Download URL rfwc-0.1.2-py3-none-any.whl
Size 33.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e8bb9ee9123e49628762bfc4c23bbce06faf2933c5d3777ae2ef86cfe03f905
BLAKE2b-256 checksum
How to use checksums
14911c4eac5173c5fe110cd3e2d5011dd13835825e154b6331c7571a11d169f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.0

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