DEV Community

Mahmud Rahman
Mahmud Rahman

Posted on

Introducing LPTE: An Offline, Open-Source Profanity & Toxicity Detection Engine for Python

Content moderation is becoming a requirement for almost every modern application—whether it's a chat app, forum, social platform, or AI-powered product.

Most existing solutions rely on cloud APIs, which introduce latency, privacy concerns, recurring costs, and vendor lock-in.

I wanted something different.

So I built LPTE (Local Profanity & Toxicity Engine)—a lightweight, open-source Python library that performs profanity and toxicity detection entirely offline.

Why LPTE?

  • ⚡ Detects toxic text in under 25 ms
  • 🔒 Runs completely offline—no cloud services required
  • 🌍 Supports English and Bengali out of the box
  • ➕ Add support for any language using a simple JSON file
  • 🛡️ Detects common bypass techniques such as:

    • Leetspeak
    • Character insertion
    • Zero-width characters
    • Word splitting

How It Works

Instead of relying on a single matching strategy, LPTE combines multiple signals:

  • Exact word matching
  • Language-aware stemming
  • Concatenation detection
  • Fuzzy matching
  • Context-aware rules to reduce false positives

This layered approach helps improve detection accuracy while keeping performance fast enough for real-time applications.

Platform Support

LPTE includes wrappers for:

  • Python
  • Flutter
  • Android
  • iOS
  • React Native
  • Node.js
  • Go
  • Rust
  • .NET
  • PHP

Current Status

  • ✅ 78 automated tests passing
  • ✅ MIT Licensed
  • ✅ Fully open source

Live Demo

Try it here:

https://lpte-demo.onrender.com

GitHub

Source code:

https://github.com/mahmud-r-farhan/lpte

Looking for Feedback

LPTE is still evolving, and I'd really appreciate feedback from the developer community.

If you find the project useful:

  • ⭐ Star the repository
  • 🐛 Report issues
  • 💡 Suggest improvements
  • 🤝 Contribute with pull requests

I'd love to hear your thoughts on improving multilingual profanity and toxicity detection while keeping everything fast, lightweight, and offline.

Top comments (0)