Skip to main content
All posts
5 min read

Building a Filipino Profanity Detection API with Laravel

LaravelREST APIPHP

Most content moderation libraries are built for English. That is a real problem in the Philippines, where online communities mix Tagalog, regional dialects, and code-switched English — and where a filter that blocks harmless words is worse than no filter at all.

I set out to build a REST API that detects Filipino profanity reliably, integrates easily into any frontend, and stays cheap to run. This post walks through the design decisions and what I would do differently next time.

Why not just use a generic profanity list?

  • Generic lists miss Filipino terms entirely, including regional variations.
  • English lists over-block: words that are innocuous in Filipino can match an English curse word, or vice versa.
  • Slang evolves fast, so the dictionary needs to be curatable without redeploys.

How the API works

Requests are tokenized, normalized (lowercase, trimmed spacing, common leetspeak substitutions), then matched against a curated Filipino dictionary. The Laravel backend exposes simple JSON endpoints so moderation can be wired into posts, comments, or messaging with a few lines of code:

POST /api/detect
{
  "text": "sana all mabait ka naman"
}

{
  "profane": false,
  "matches": [],
  "normalized": "sana all mabait ka naman"
}

Trade-offs I accepted

  • Dictionary matching over ML: transparent, fast, and cheap, but needs continuous curation as slang changes.
  • Server-side detection keeps the dictionary private but costs one HTTP round-trip per request.
  • Normalization improves recall but risks false positives — I tuned thresholds conservatively.

What I learned

  • Ship the simplest correct version first — a word list beats a half-trained model.
  • Language-specific tooling is an underserved niche; domain knowledge is a real advantage.
  • Making the dictionary data-driven (rather than hardcoded) pays off the first time a new slang term appears.

The API is live and has been integrated by external services. If you build Filipino products, giving content moderation a proper language-aware layer is one of those small investments with outsized product impact.