GLINR Studio LogoTypeWeaver

Quick Start

Get started with Glin-Profanity in under 5 minutes

Edit on GitHub

Minimal working examples for both JavaScript and Python. Get profanity detection running in under 5 minutes.

Basic Usage

Import and basic check
// Import the core detection function
import { checkProfanity } from 'glin-profanity';

// Basic profanity detection
const result = checkProfanity("This is damn good!", {
  languages: ['english'],
  autoReplace: true
});

// Log the result
console.log(result);

Expected Output:

{
  "containsProfanity": true,
  "profaneWords": ["damn"],
  "processedText": "This is **** good!",
  "matches": [
    {
      "word": "damn",
      "index": 8,
      "severity": 1
    }
  ],
  "severityMap": { "damn": 1 }
}
Import and basic check
# Import the Filter class
from glin_profanity import Filter

# Initialize filter with configuration
filter_instance = Filter({
    "languages": ["english"],
    "auto_replace": True
})

# Check profanity in text
result = filter_instance.check_profanity("This is damn good!")

# Print the result
print(result)

Expected Output:

{
  "contains_profanity": true,
  "profane_words": ["damn"],
  "processed_text": "This is **** good!",
  "severity_map": {"damn": 1},
  "matches": [
    {
      "word": "damn", 
      "index": 8, 
      "severity": 1
    }
  ]
}

Simple Word Check

Boolean word checking
// Import
import { isWordProfane } from 'glin-profanity';

// Basic boolean checks
console.log(isWordProfane('hello'));    // false
console.log(isWordProfane('damn'));     // true
console.log(isWordProfane('sh*t'));     // true
Boolean word checking
# Import
from glin_profanity import Filter

filter_instance = Filter()

# Basic boolean checks  
print(filter_instance.is_profane('hello'))    # False
print(filter_instance.is_profane('damn'))     # True
print(filter_instance.is_profane('sh*t'))     # True

Context-Aware Demo

Glin-Profanity's advanced context analysis can distinguish between positive and negative uses of the same words:

Glin-Profanity Context-Aware Demo showing positive context vs negative context detection

Context-Aware Intelligence: Glin-Profanity analyzes sentiment and context to reduce false positives by up to 85%. Words like "damn" in "damn good coffee" are recognized as positive expressions.

React Integration

React hook usage
import React, { useState } from 'react';
import { useProfanityChecker } from 'glin-profanity';

function ChatInput() {
  const [message, setMessage] = useState('');
  const { checkText, result, isDirty } = useProfanityChecker({
    languages: ['english'],
    enableContextAware: true
  });

  const handleSubmit = (e) => {
    e.preventDefault();
    const checkResult = checkText(message);
    
    if (checkResult.containsProfanity) {
      alert(`Profanity detected: ${checkResult.profaneWords.join(', ')}`);
      return;
    }
    
    // Send clean message
    console.log('Clean message sent:', message);
  };

  return (
    <form onSubmit={handleSubmit}>
      <input
        value={message}
        onChange={(e) => setMessage(e.target.value)}
        placeholder="Type your message..."
        style={{
          borderColor: result?.containsProfanity ? 'red' : 'green'
        }}
      />
      <button type="submit" disabled={result?.containsProfanity}>
        {result?.containsProfanity ? 'Contains Profanity' : 'Send Message'}
      </button>
    </form>
  );
}

Both JavaScript and Python implementations use the same dictionaries and algorithms, ensuring identical results across platforms.

Verify Your Setup

Test your installation with these quick verification scripts:

test-glin-profanity.js
import { checkProfanity, isWordProfane } from 'glin-profanity';

// Test basic detection
console.log('✓ Testing basic detection...');
const result = checkProfanity('This is a test');
console.log(`Clean text detection: ${!result.containsProfanity ? '✓ PASS' : '✗ FAIL'}`);

// Test profanity detection  
console.log('✓ Testing profanity detection...');
const profaneResult = checkProfanity('This is damn annoying');
console.log(`Profanity detection: ${profaneResult.containsProfanity ? '✓ PASS' : '✗ FAIL'}`);

// Test word checking
console.log('✓ Testing word checking...');
console.log(`Word check: ${isWordProfane('hello') === false ? '✓ PASS' : '✗ FAIL'}`);

console.log('\n🎉 All tests passed! Glin-Profanity is ready to use.');
test_glin_profanity.py
from glin_profanity import Filter

# Initialize filter
filter_instance = Filter()

# Test basic detection
print('✓ Testing basic detection...')
result = filter_instance.check_profanity('This is a test')
print(f'Clean text detection: {"✓ PASS" if not result["contains_profanity"] else "✗ FAIL"}')

# Test profanity detection
print('✓ Testing profanity detection...')
profane_result = filter_instance.check_profanity('This is damn annoying')
print(f'Profanity detection: {"✓ PASS" if profane_result["contains_profanity"] else "✗ FAIL"}')

# Test word checking
print('✓ Testing word checking...')
print(f'Word check: {"✓ PASS" if filter_instance.is_profane("hello") == False else "✗ FAIL"}')

print('\n🎉 All tests passed! Glin-Profanity is ready to use.')

Ready for Production: Once your verification tests pass, Glin-Profanity is ready for use in your production applications with sub-millisecond detection speeds and 23-language support.

Next Steps