Skip to content
Side ID ~ edited this page Apr 15, 2025 · 2 revisions

ID-Profanity-Filter Wiki

Sidebar

Table of Contents

  1. [Overview](#overview)
  2. [Installation](#installation)
  3. [Basic Usage](#basic-usage)
  4. [Advanced Configuration](#advanced-configuration)
  5. [API Reference](#api-reference)
  6. [Presets](#presets)
  7. [Regional Support](#regional-support)
  8. [Categories](#categories)
  9. [Contributing](#contributing)
  10. [License](#license)

Overview

ID-Profanity-Filter is a comprehensive JavaScript/TypeScript library designed to detect, censor, and analyze profane words in Indonesian and regional languages. The library provides advanced features for content moderation and text filtering.

Key Features

  • ๐Ÿ” Profanity Detection: Identifies offensive words in Indonesian text
  • โš ๏ธ Content Analysis: Analyzes severity and categories of profane words
  • ๐Ÿ”’ Censorship: Offers customizable word censoring options
  • ๐Ÿ—บ๏ธ Regional Language Support: Covers words from various Indonesian regions
  • ๐Ÿง  Smart Detection: Identifies spelling variations, split words, and word similarities
  • ๐Ÿ”  Levenshtein Detection: Detects modified or obfuscated profane words
  • ๐Ÿ›ก๏ธ Presets: Ready-to-use filter presets
  • ๐Ÿ”ง Customization: Options to add whitelist and custom word lists

Installation

Install the library using your preferred package manager:

npm install @sideid/id-profanity-filter
# or
yarn add @sideid/id-profanity-filter
# or
pnpm add @sideid/id-profanity-filter

Basic Usage

Initializing the Filter

import IDProfanityFilter from '@sideid/id-profanity-filter';

// Create a filter instance
const filter = new IDProfanityFilter();

// Check for profanity
const text = 'Dasar anjing kamu, jangan banyak bacot!';
const hasProfanity = filter.isProfane(text);
console.log(hasProfanity); // Output: true

// Filter profane words
const result = filter.filter(text);
console.log(result.filtered); 
// Output: "Dasar ***** kamu, jangan banyak *****!"

Advanced Configuration

Customizing Filter Options

const filter = new IDProfanityFilter({
  replaceWith: '#',
  fullWordCensor: false,
  detectLeetSpeak: true,
  categories: ['sexual', 'slur'],
  regions: ['jawa', 'general'],
  severityThreshold: 0.7,
  
  // Advanced options
  useRandomGrawlix: true,
  keepFirstAndLast: true,
  indonesianVariation: true,
  detectSimilarity: true,
  detectSplit: true,
  useLevenshtein: true
});

API Reference

Main Methods

  • filter(text: string): Censors profane words
  • isProfane(text: string): Checks if text contains profanity
  • analyze(text: string): Provides detailed analysis of profane content
  • batchAnalyze(texts: string[]): Analyzes multiple texts
  • analyzeBySentence(text: string): Analyzes text by sentence
  • analyzeWithContext(text: string): Analyzes text with surrounding context

Presets

Filter Presets

  • strict: Most rigorous filtering
  • moderate: Medium-level filtering
  • light: Minimal filtering
  • childSafe: Extremely strict filtering

Category Presets

  • sexual: Sexual content
  • insults: Insulting words
  • profanity: General profanity

Regional Presets

  • general: General Indonesian words
  • jawa: Javanese words
  • sunda: Sundanese words
  • betawi: Betawi words
  • batak: Batak words

Regional Support

The library supports profane words from various Indonesian regions:

  • ๐Ÿ‡ฎ๐Ÿ‡ฉ General Indonesian
  • ๐Ÿ๏ธ Javanese
  • ๐Ÿž๏ธ Sundanese
  • ๐Ÿ™๏ธ Betawi
  • ๐ŸŒ‹ Batak

Categories

Words are categorized into:

  • sexual: Sexual content
  • insult: Insulting words
  • profanity: General profanity
  • slur: Derogatory terms
  • drugs: Drug-related terms
  • disgusting: Offensive words
  • blasphemy: Religious insults

Contributing

We welcome contributions! To contribute:

  1. Fork the repository
  2. Create a new branch
  3. Make your changes
  4. Submit a pull request

Adding New Words

To add a new word to the database, create a pull request with changes in src/constants/categories/ or src/constants/regions/:

{
  "word": "profane_word",
  "category": "insult",
  "region": "general",
  "severity": 0.7,
  "aliases": ["variations"],
  "description": "Word explanation",
  "context": "Usage context"
}

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

For questions, issues, or suggestions, please open an issue in the GitHub repository.