new Filter(useDefaultWords, excludeWords, replaceBy)
Filter object constructor
Parameters:
Name | Type | Description |
---|---|---|
useDefaultWords |
boolean | Use the default set of obscene words |
excludeWords |
array | Words to exclude from obscenity set |
replaceBy |
string | Character used to replace obscene words |
Methods
addWord(word, labels)
Add single word to the set of obscenity words
Parameters:
Name | Type | Description |
---|---|---|
word |
string | |
labels |
array | Labels of the new word: Existing labels are [PN, RT, IN, NO] |
addWords(words, labels)
Add new words to obscenity set
Parameters:
Name | Type | Description |
---|---|---|
words |
array | New words to add to obscenity set |
labels |
array | An array of arrays with all the labels for each new word |
containsObscenity(phrase) → {boolean}
Checks if a phrase/sentence contains any obscene word. Splits the string by whitespace before checking each word for obscenity.
Parameters:
Name | Type | Description |
---|---|---|
phrase |
string |
Returns:
- Type
- boolean
getLabels(word) → {array}
Returns the categorizing labels for a given obscene word. Returns an empty array if isPure(word) == true.
Parameters:
Name | Type | Description |
---|---|---|
word |
string |
Returns:
- Type
- array
isPure(word) → {boolean}
Checks if a word is obscene. Returns true if the word is not obscene
Parameters:
Name | Type | Description |
---|---|---|
word |
string |
Returns:
- Type
- boolean
removeWord(word)
Remove single word from the set of obscenity words
Parameters:
Name | Type | Description |
---|---|---|
word |
string |
removeWords(words)
Remove words from the set of obscenity words
Parameters:
Name | Type | Description |
---|---|---|
words |
list | A list of strings |
scrub(phrase) → {string}
Scrubs all obscene words and replaces them with asterisk characters.
Parameters:
Name | Type | Description |
---|---|---|
phrase |
string |
Returns:
- Type
- string