/** * Supported language codes for profanity detection */ type LanguageCode = 'en' | 'es' | 'fr' | 'de' | 'it' | 'pt' | 'ru' | 'zh' | 'ja' | 'ar' | 'hi' | 'ko' | 'nl' | 'sv' | 'pl' | 'he' | 'tr' | 'auto'; /** * Severity levels for profanity classification */ declare enum SeverityLevel { LOW = 1, MEDIUM = 2, MODERATE = 2, HIGH = 3, SEVERE = 4 } /** * Categories of profanity content * String union type to support diverse categorizations across languages */ type ProfanityCategory = 'general' | 'profanity' | 'sexual' | 'violence' | 'hate_speech' | 'discrimination' | 'substance_abuse' | 'religious' | 'political' | 'body_parts' | 'scatological' | 'slurs' | 'disability' | 'ethnic' | 'lgbtq' | 'racial' | 'abbreviation' | 'ableist' | 'adjective' | 'age' | 'ageist' | 'anatomical' | 'anatomy' | 'animal' | 'animal_comparisons' | 'animal_insult' | 'appearance' | 'arabic_loanword' | 'archaic' | 'avoidance' | 'behavior' | 'biblical' | 'blasphemy' | 'bodily_function' | 'body_shaming' | 'borrowed' | 'caste' | 'chaos' | 'character' | 'childish' | 'class' | 'classist' | 'cleanliness' | 'command' | 'commands' | 'complaining' | 'compound' | 'condition' | 'container' | 'context_dependent' | 'creative' | 'creepy' | 'criminal' | 'curse' | 'damnation' | 'death_threat' | 'death_wish' | 'derogatory' | 'diminutive' | 'direct_address' | 'direct_insult' | 'directness' | 'discriminatory' | 'disease' | 'disgust' | 'dismissal' | 'dismissive' | 'disrespect' | 'drug_reference' | 'drugs' | 'duty' | 'egyptian_specific' | 'emotion' | 'emphatic' | 'endearment' | 'english_loan' | 'euphemism' | 'exclamation' | 'extreme' | 'extreme_threat' | 'extremely_derogatory' | 'extremely_offensive' | 'extremely_vulgar' | 'family' | 'family_honor' | 'family_insult' | 'female_specific' | 'finality' | 'flemish' | 'food' | 'formal' | 'gender' | 'gender_slur' | 'gendered' | 'generational' | 'gesture' | 'gulf_specific' | 'homeless' | 'homophobic' | 'honor' | 'humorous' | 'illegitimate_birth' | 'impatience' | 'imperative' | 'insult' | 'intelligence' | 'intensifier' | 'internet_euphemism' | 'internet_gaming' | 'internet_memes' | 'laziness' | 'levantine_specific' | 'lgbtq_slur' | 'maghrebi_specific' | 'male_specific' | 'masturbation' | 'mat_system' | 'memory_erasure' | 'mental' | 'mental_health' | 'mess' | 'metaphorical' | 'mild' | 'mild_profanity' | 'mild_vulgar' | 'military' | 'misogynistic' | 'modern' | 'moral' | 'mythological' | 'nationality' | 'nonsense' | 'noun' | 'object' | 'objectification' | 'offensive' | 'passive_insult' | 'phrase' | 'physical_appearance' | 'physical_threat' | 'pimp' | 'pity' | 'positive' | 'prefixed' | 'prison' | 'profession' | 'pronouns' | 'quantity' | 'racial_slur' | 'racist' | 'regional' | 'relationship' | 'rude_command' | 'sarcasm' | 'seniority' | 'sexual_undertone' | 'situation' | 'slang' | 'slur' | 'social' | 'social_class' | 'socially_acceptable' | 'socioeconomic' | 'suffix' | 'supernatural' | 'surprise' | 'threat' | 'threats' | 'traditional' | 'transphobic' | 'verb' | 'violent' | 'vulgar' | 'vulgar_command' | 'vulgar_verb' | 'weakness' | 'weather' | 'worthlessness'; /** * Detection result for a single word or phrase */ interface DetectionMatch { /** The original word/phrase that was detected */ word: string; /** The matched profane word from the database */ match: string; /** Position in the text where the match starts */ start: number; /** Position in the text where the match ends */ end: number; /** Severity level of the detected profanity */ severity: SeverityLevel; /** Categories this profanity belongs to */ categories: ProfanityCategory[]; /** Detected language of the word */ language: LanguageCode; /** Confidence score (0-1) for the detection */ confidence: number; } /** * Complete detection result for analyzed text */ interface DetectionResult { /** Original input text */ originalText: string; /** Text with profanity filtered/censored */ filteredText: string; /** Whether any profanity was detected */ hasProfanity: boolean; /** Total number of profane words detected */ totalMatches: number; /** Highest severity level found in the text */ maxSeverity: SeverityLevel; /** All detection matches found */ matches: DetectionMatch[]; /** Languages detected in the text */ detectedLanguages: LanguageCode[]; /** Overall confidence score for the analysis */ confidence: number; /** Processing time in milliseconds */ processingTime: number; } /** * Language metadata information */ interface LanguageMetadata { readonly name: string; readonly code: LanguageCode; readonly version: string; readonly wordCount: number; readonly lastUpdated: string; readonly contributors?: readonly string[]; } /** * Word entry in language data */ interface WordEntry { readonly word: string; readonly severity: SeverityLevel; readonly categories: readonly ProfanityCategory[]; readonly variations?: readonly string[]; readonly case_sensitive?: boolean; readonly context_notes?: string; readonly target_type?: string; } /** * Simplified static language data structure for tree-shaking optimization * This is a simplified version that only contains essential word data */ interface StaticLanguageData { readonly metadata: LanguageMetadata; readonly words: readonly WordEntry[]; } /** * Configuration options for the profanity detector */ interface DetectorConfig { /** Languages to check for profanity */ languages: LanguageCode[]; /** Minimum severity level to detect */ minSeverity: SeverityLevel; /** Categories of profanity to detect */ categories: ProfanityCategory[]; /** Whether to use fuzzy matching for variations */ fuzzyMatching: boolean; /** Fuzzy matching threshold (0-1) */ fuzzyThreshold: number; /** Custom words to add to the filter */ customWords: CustomWord[]; /** Words to whitelist (never flag as profanity) */ whitelist: string[]; /** Whether to detect profanity in different scripts/alphabets */ detectAlternateScripts: boolean; /** Whether to normalize text before detection */ normalizeText: boolean; /** Replacement character/string for censoring */ replacementChar: string; /** Whether to preserve word structure when censoring */ preserveStructure: boolean; /** Static language data for tree-shaking (bypasses dynamic loading) */ languageData?: Partial>; } /** * Custom word definition for extending the profanity database */ interface CustomWord { /** The word or phrase to detect */ word: string; /** Language this word belongs to */ language: LanguageCode; /** Severity level of this word */ severity: SeverityLevel; /** Categories this word belongs to */ categories: ProfanityCategory[]; /** Alternative spellings or variations */ variations?: string[]; /** Regular expression pattern (if word contains regex) */ pattern?: string; /** Whether this word should be case-sensitive */ caseSensitive?: boolean; } /** * Language detection result */ interface LanguageDetection { /** Detected language code */ language: LanguageCode; /** Confidence score for this language (0-1) */ confidence: number; /** Portion of text that contributed to this detection */ sample: string | undefined; } /** * Statistics about the profanity database */ interface DatabaseStats { /** Total number of words in the database */ totalWords: number; /** Words count by language */ wordsByLanguage: Record; /** Words count by severity */ wordsBySeverity: Record; /** Words count by category */ wordsByCategory: Record; /** Last updated timestamp */ lastUpdated: Date; /** Database version */ version: string; } /** * Filter operation modes */ declare enum FilterMode { /** Replace with asterisks or replacement characters */ CENSOR = "censor", /** Remove profane words entirely */ REMOVE = "remove", /** Replace with alternative words */ REPLACE = "replace", /** Mark but don't modify the text */ DETECT_ONLY = "detect_only" } /** * Text analysis options */ interface AnalysisOptions { /** Filter mode to apply */ filterMode: FilterMode; /** Whether to return detailed match information */ includeMatches: boolean; /** Whether to include confidence scores */ includeConfidence: boolean; /** Whether to measure processing time */ measurePerformance: boolean; /** Maximum text length to process */ maxLength?: number; } /** * Error types that can occur during detection */ declare enum DetectionErrorType { INVALID_INPUT = "invalid_input", LANGUAGE_NOT_SUPPORTED = "language_not_supported", TEXT_TOO_LONG = "text_too_long", CONFIGURATION_ERROR = "configuration_error", DATABASE_ERROR = "database_error" } /** * Detection error with context information */ interface DetectionError extends Error { type: DetectionErrorType; code: string; context?: Record; } /** * Enhanced detection match with additional metadata (re-export from core) */ interface EnhancedDetectionMatch extends DetectionMatch { /** Detailed position information */ position: { absoluteStart: number; absoluteEnd: number; lineNumber: number; columnStart: number; columnEnd: number; wordIndex: number; sentenceIndex: number; }; /** Context around the match */ context: { before: string; after: string; sentence: string; }; /** Alternative suggestions for replacement */ suggestions: string[]; /** Reason for detection */ detectionReason: string; /** Whether this is a fuzzy match */ isFuzzyMatch: boolean; /** Edit distance for fuzzy matches */ editDistance?: number; /** Original match score before confidence adjustments */ rawScore: number; } export { type AnalysisOptions as A, type CustomWord as C, type DatabaseStats as D, type EnhancedDetectionMatch as E, FilterMode as F, type LanguageCode as L, type ProfanityCategory as P, SeverityLevel as S, type WordEntry as W, type DetectionError as a, DetectionErrorType as b, type DetectionMatch as c, type DetectionResult as d, type DetectorConfig as e, type LanguageDetection as f, type LanguageMetadata as g, type StaticLanguageData as h };