DotnetBadWordDetector 1.0.1
dotnet add package DotnetBadWordDetector --version 1.0.1
NuGet\Install-Package DotnetBadWordDetector -Version 1.0.1
<PackageReference Include="DotnetBadWordDetector" Version="1.0.1" />
paket add DotnetBadWordDetector --version 1.0.1
#r "nuget: DotnetBadWordDetector, 1.0.1"
// Install DotnetBadWordDetector as a Cake Addin #addin nuget:?package=DotnetBadWordDetector&version=1.0.1 // Install DotnetBadWordDetector as a Cake Tool #tool nuget:?package=DotnetBadWordDetector&version=1.0.1
.NET Bad Word Detector
This is a fast and robust library that detects offensive language within text strings. It currently supports only English language, more languages will be added soon.
How It Works
This library uses a logistic regression ML.NET model trained on thousands of human-labeled words. The trained model then was loaded as a resource for this lib and it is consulted on every new prediction.
Why to use this library?
Up to this moment all .NET profanity detection libraries use hard-coded lists of bad words to detect profanity, for instance, ProfanityDetector uses this list stored in memory, there are obvious glaring issues with this approach, and while they might be performant, these list based libraries are not comprehensive, they are easily outperformed by misspelling and by the human creativity to replace letters for meaningless chars creating new words that are perceived as curse words (e.g. house and h0us3).
Performance
In a single prediction this library was 618 times faster than the most downloaded .NET package for detecting profanity. For 100 successive predictions it was around 24 times faster.
Package | 1 Prediction | 10 Predicitons | 100 predictions |
---|---|---|---|
.Net Bad Word Detector | 0.0462 ms | 1.5508 ms | 4.1887 ms |
ProfanityDetector | 28.5823 ms | 42.4606 ms | 102.0750 ms |
PC specs: Dell Inspiron 13, I7 8th gen, 16 GB.
How to install
dotnet add package DotnetBadWordDetector
How to use it
var detector = new ProfanityDetector();
if(detector.IsProfane("foo bar")){
//do something
}
It is strongly suggested to keep the library always loaded in memory to increase its performance, it uses very little memory (less than 100 KB).
Accuracy, AUC and F1 score
Model quality metrics evaluation
--------------------------------
Accuracy: 98.43%
Auc: 99.49%
F1Score: 97.25%
Caveat
This library is not perfect, it is not 100% precise, and it is context-free, e.g. it can not detect profane phrases consisted of decent words. Also people diverge on what is considered profane.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Microsoft.ML (>= 1.7.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on DotnetBadWordDetector:
Package | Downloads |
---|---|
Veltonsoft.BrawlStars.V24.MonolithCore
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.