Jan 1, 2022

Profanity Detector

A Python program for detecting bad words in a given text.

#BadWordDetector: A Profanity Filter for Text

Welcome to the BadWordDetector project! This tool is designed to identify and flag profanity in text by comparing input strings against a customizable list of bad words. It's perfect for moderating content in forums, chat applications, or any platform that aims to maintain a clean and respectful user environment.

Click here to go to the github repository

#Features

  • Customizable Profanity List: Easily update the list of profane words to suit the needs of your platform.
  • Intelligent Detection: Utilizes a similarity algorithm to catch variations of bad words, enhancing its effectiveness.
  • Efficiency: Optimized for fast processing, ensuring minimal impact on application performance.
  • Simplicity: Designed with an easy-to-understand API, making integration seamless.

#Getting Started

To get started with BadWordDetector, follow these simple steps.

#Prerequisites

Ensure you have Python installed on your system. This project has been tested with Python 3.8 and above.

#Installation

  1. Clone the repository:
git clone https://github.com/R1ck404/ProfanityDetection.git
cd BadWordDetector
  1. Prepare your bad words list:

Create a text file named badwords.txt and list each bad word on a new line. Place this file in the root directory of the project.

#Usage

To use the BadWordDetector in your project, simply follow the example below:

main.py
from BadWordDetector import BadWordDetector

# Initialize the detector with your bad words list
detector = BadWordDetector('badwords.txt')

# Example text to check for profanity
text = "This is a test string to check for bad words like **** and ****."

# Detect bad words
detected_words = detector.detect(text)

# Process the results
if detected_words:
    for word in detected_words:
        print(f'{word[0]} ({word[1]}, {word[2]*100:.2f}% similarity)')
else:
    print('No bad words detected')

#How It Works

  • Reading the List: On initialization, BadWordDetector reads from the specified bad words list file and stores it for future reference.
  • Detection: When detect is called with a piece of text, the detector splits the text into words and checks each word against the bad words list, considering similarities to catch variations.
  • Similarity Calculation: It calculates similarity using letter pair matching, allowing it to detect even obfuscated profanity with a high degree of accuracy.

#Contributing

We welcome contributions to the BadWordDetector project! Please feel free to contribute by submitting pull requests or creating issues for bugs and feature requests.


Enjoy using BadWordDetector, and help us make the online world a more respectful place!