UNPKG

deep-profanity-filter

Version:

A thorough profanity filter that considers most common circumventions. Works with your custom list of blocked and whitelisted words and phrases. Identifies and/or replaces bad words. Works with *wildcards* at *start and/or end* of words.

64 lines (63 loc) 3.47 kB
/** * Replaces all emojis in a text that feature a letter with * normal latin characters. * Example: "🇬⭕ 🔛" turns into "go on" or * "🅿🇺®️💰🇪" turns into "purse". * Note: This does NOT replace random emojis used to represent * or mask letters, such as '🌸' representing an 'O'. * * Suggested usage: `textToLatin(unEmoji(inputText))` * @param {string} inputText - The text from which you would like to remove all text based emojis. * @returns the input text, with all letter based emojis transformed to become text. */ export declare function unEmoji(inputText: string): string; /** * Removes most common accents from characters. * Example: The text "Z̵̡̭͝ả̶̬̘̈́l̶̜͗g̵̜̲͒́o̶̞̅̊" becomes "Zalgo", * the text "à-côtés" becomes "a-cotes", * non-latin characters stay non-latin, e.g. "ᑕⓞ֑ο̤͕𝕃ܑׅ" becomes "ᑕⓞο𝕃". * @param {string} inputText - The text for which you wish to have all * accents removed. * @returns the input text, stripped of all accents. */ export declare function removeTextAccents(inputText: string): string; /** * Converts a text of fancy unicode font to latin alphabet characters. * This translation happens based on "visual appearance" of the letters, * so if you do this to text that is written in a language of non-latin * alphabet, you will get weird outputs. * * Disclaimer: This may at times mistranslate messages, and the list of * characters that get converted is most likely not complete, although * it is very thoroughly assembled. It will remove most common accents, * and returns a latin string in lower case letters. Any characters that * could not be mapped to latin characters will still appear in the string. * * Example: * "ᵺⓘ꯱ ₮Ꮛ乂Շ" would turn into "this text" or "Z̵̡̭͝ả̶̬̘̈́l̶̜͗g̵̜̲͒́o̶̞̅̊" turns into "zalgo", or * "ᑕⓞ֑ο̤͕𝕃ܑׅ" turns into "cool". * * Suggested usage: `textToLatin(unEmoji(inputText))` * @param {string} inputText - The text which you would like to convert to latin * @returns the input text, with foreign or special alphabet letters translated * to latin lower case characters */ export declare function textToLatin(inputText: string): string; /** * For any given input text, reduce any repeating characters to a given maximum amount of repetitions. * * As an example, the input string: `"heeellllooooo"` becomes: `"heelloo"` if that number is 2, or * `"heeelllooo"` if that number is 3, or `helo` if that number is 1. * * For English, it is recommended to not use values lower than 2. If this preprocessing is used, make * sure that the bad words and allowed terms also feature at most the same number of repeated characters. * I.e. if using this with the number "2", there is no use of putting words like "helllo" on the lists. * @param inputText - The text from which to remove repeat characters. * @param maxAllowedCharsInSequence - The maximum number of characters in sequence (such as "aaa", "bbb", * ...) that are allowed to remain in the input string. `Recommended: 2 or 3`, depending on the language * of your input text. * @returns The input text with all repeat characters that occur more than the max amount in sequence * removed. * @throws If `maxAllowedCharsInSequence` is not an integer (such as 1.5) or if it is 0 or less. */ export declare function reduceRepeatCharacters(inputText: string, maxAllowedCharsInSequence?: number): string;