Expletive
A profanity detection and sanitization library.
Summary
configure(options) | Returns a configuration to pass to other functions |
configure(config, options) | Updates the configuration. Accepts the same options as |
profane?(string, config) | Returns |
profanities(string, config) | Returns a list of profanities found in the given string. All occurences are returned, duplicates may thus occur |
sanitize(string, config) | Replace all profanities by a placeholder as defined by the |
sanitize(string, config, replacement) | Replace all profanities by a placeholder as defined by the given |
Types ↑
replacement :: :default | :garbled | :stars | :vowels | :nonconsonants | String.t | {:repeat, String.t} | :keep_first_letter | {:keep_first_letter, String.t}
Functions
Specs:
- configure(list) :: Expletive.Configuration.t
Returns a configuration to pass to other functions.
:blacklist
- A list of words which are considered profane (if a string is given, it will be split on whitespace to create the world list):whitelist
- A list of words which are allowed even if they’re also present in the blacklist (if a string is given, it will be split on whitespace to create the world list):replacement
- A replacement strategy::garbled
- Replace by a random permutation of$@!#%
(default):stars
- Replace all characters by*
:vowels
- Replace all vowels of the offending word by*
:nonconsonants
- Replace all non-consonants of the offending word by*
string
- Replace the occurence by the given string{:repeat, string}
- Replace all characters by the given string:keep_first_letter
- Replace all characters but the first one by*
{:keep_first_letter, string}
- Replace all characters but the first one by the given string
Specs:
- configure(Expletive.Configuration.t, list) :: Expletive.Configuration.t
Updates the configuration. Accepts the same options as configure/1
Specs:
- profane?(String.t, Expletive.Configuration.t) :: boolean
Returns true
if the given string contains a word considered profane by the given configuration
Specs:
Returns a list of profanities found in the given string. All occurences are returned, duplicates may thus occur
Specs:
Replace all profanities by a placeholder as defined by the replacement
option of the current configuration