Filter

Filter

new Filter(useDefaultWords, excludeWords, replaceBy)

Source:

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)

Source:

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)

Source:

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}

Source:

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}

Source:

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}

Source:

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)

Source:

Remove single word from the set of obscenity words

Parameters:
Name Type Description
word string

removeWords(words)

Source:

Remove words from the set of obscenity words

Parameters:
Name Type Description
words list

A list of strings

scrub(phrase) → {string}

Source:

Scrubs all obscene words and replaces them with asterisk characters.

Parameters:
Name Type Description
phrase string
Returns:
Type
string