This package is designed to help you easily identify and detect profanity or bad words within a given sentence or string. It leverages a simple binary classifier that has been built and trained for accurate and efficient detection of inappropriate language. The model was created using ML.Net and the dataset for training was obtained from Surge AI
To get started, install the Profanity Detector NuGet package into your project. You can do this using the following command in the Package Manager Console:
NuGet\Install-Package nikolliervin.profanity-detector -Version 1.0.5
dotnet add package nikolliervin.profanity-detector --version 1.0.5
Once the package is installed, integrating it into your code is straightforward. Here's a simple example of how to use the Profanity Detector:
using profanity_detector;
class Program
{
static void Main(string[] args)
{
// Instantiate the ProfanityDetection class
var profanityDetector = new ProfanityDetection();
// Detect profanity in a string
var hasProfanity = profanityDetector.isToxic("string to detect");
// 'hasProfanity' will be true if profanity is detected, otherwise false
if (hasProfanity)
{
Console.WriteLine("Profanity detected in the provided string!");
// Handle the profanity as needed
}
else
{
Console.WriteLine("No profanity detected. The string is clean!");
}
}
}
The Profanity Detector utilizes a simple binary classifier that has been built and trained to distinguish between clean and profane language. The underlying algorithm analyzes the input string and returns true
if it contains bad words and false
otherwise.
The machine learning model, trained using ML.NET, showed a good level of accuracy on the given dataset.
- Accuracy: 80.90%
While the Profanity Detector is effective in identifying common profanity and bad words, but it may not be exhaustive. I am actively working to increase the accuracy of the detection.
I welcome your feedback! If you encounter any issues, have suggestions for improvement, or want to contribute to the project, please visit my GitHub repository and create an issue or pull request.