A lightweight, resilient Filipino/Tagalog profanity filter with support for leet-speak and multiple variations.
npm install tagalog-profanity-filterg@g0), punctuation (gago!), symbols inside words (p_u_t_a), and spacing
vovo (bobo), taena (tangina), and ug0k
atup (puta) or ogag (gago)
import) and CommonJS (require)
bash
npm install tagalog-profanity-filter
`
Interactive Demo
To run the local demo:
`bash
npm run demo
`
Then open http://localhost:3000.
Quick Start
`typescript
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
$3
`typescript
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 details
`
$3
- 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 with censored text, hasProfanity boolean, and matches array.
- addWords(words: string[])` - Add words to the filter dynamically.