tagalog-profanity-filter
v1.0.0
Published
A lightweight, resilient Filipino/Tagalog profanity filter with support for leet-speak and multiple variations.
Maintainers
Readme
Tagalog Profanity Filter
A lightweight, resilient, and configurable profanity filter for Filipino/Tagalog, built with TypeScript.
Features
- ⚡ Fast: Uses Trie matching for O(n) performance
- 🛡️ Resilient: Handles leet-speak (
g@g0), punctuation (gago!), symbols inside words (p_u_t_a), and spacing - 🗣️ Slang Support: Detects common variations like
vovo(bobo),taena(tangina), andug0k - 🔄 Reverse Matching: Detects reversed slang e.g.,
atup(puta) orogag(gago) - 🔧 Configurable: whitelist, blacklist, custom placeholders
- 📦 Dual Package: Supports both ESM (
import) and CommonJS (require) - 📝 TypeScript: Full type definitions included
- 🎮 Demo Included: Interactive playground to test filters
Installation
npm install tagalog-profanity-filterInteractive Demo
To run the local demo:
npm run demoThen open http://localhost:3000.
Quick Start
import { isProfane, clean } from 'tagalog-profanity-filter';
// Check for profanity
if (isProfane('putangina mo')) {
console.log('Profanity detected!');
}
// Clean text
console.log(clean('putangina mo')); // Output: "********* mo"Advanced Usage
Custom Configuration
import { TagalogProfanityFilter } from 'tagalog-profanity-filter';
const filter = new TagalogProfanityFilter({
placeholder: '🤬',
replaceWholeWord: true,
whitelist: ['gaga'], // Allow specific words
blacklist: ['newbadword'] // Add custom words
});
const result = filter.check('putangina mo');
console.log(result.censored); // 🤬🤬🤬🤬🤬🤬🤬🤬🤬 mo
console.log(result.matches); // Array of match detailsMethods
isProfane(text: string): boolean- Returns true if profanity is found.clean(text: string): string- Returns the text with profanity censored.check(text: string): FilterResult- Returns detailed object withcensoredtext,hasProfanityboolean, andmatchesarray.addWords(words: string[])- Add words to the filter dynamically.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
License
MIT © JohnLicode
