This classifier attempts to detect if the text contains offensive language.

The current version only works for the English language.

OpenersPrimaryExamplesSection(Spacer1)Examples  (6)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Use the "Profanity" built-in classifier to return (RefLink[True, paclet:ref/True]) if a text contains strong language and (RefLink[False, paclet:ref/False]) otherwise:

Classify["Profanity",Import["http://www.urbandictionary.com/random.php"]]

Classify multiple examples:

Classify["Profanity",{"I love this movie", "I am so sad", "My phone broke again"}]

Obtain the probabilities for the possible classes:

Classify["Profanity", "This is a normal sentence","Probabilities"]

Obtain a (RefLink[ClassifierFunction, paclet:ref/ClassifierFunction]) for this classifier:

c=Classify["Profanity"]

Apply the classifier to a list of texts:

c[{"This is a regular sentense", "I am so sad", "My phone broke again"}]

OpenersExampleSection1(Spacer1)Scope  (1)

Load the (RefLink[ClassifierFunction, paclet:ref/ClassifierFunction]) corresponding to the built-in classifier:

c=Classify["Profanity"]

Obtain the possible classes:

Information[c,"Classes"]

OpenersExampleSection2(Spacer1)Options  (3)

OpenersExampleSubsection0(Spacer1)ClassPriors  (1)

Use a custom (RefLink[ClassPriors, paclet:ref/ClassPriors]) to restrict the possible outputs:

Classify["Profanity", "There is nothing good about the 
fellas in this movie", ClassPriors-><|True -> 0.5, False -> 0.5|>]

OpenersExampleSubsection1(Spacer1)IndeterminateThreshold  (1)

Use a custom (RefLink[IndeterminateThreshold, paclet:ref/IndeterminateThreshold]):

Classify["Profanity", "My car broke again",IndeterminateThreshold->0.99]

OpenersExampleSubsection2(Spacer1)UtilityFunction  (1)

Obtain the utility function of the classifier:

utility=Information[Classify["Profanity"],"UtilityFunction"]

Modify this utility function to penalize (RefLink[True, paclet:ref/True]) being misclassified as (RefLink[False, paclet:ref/False]):

utility[True, False]=-1.;

Classify a text using this new utility:

Classify["Profanity",Import["http://www.urbandictionary.com/random.php"],UtilityFunction->utility]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Classify, paclet:ref/Classify])  ▪  (RefLink[NetModel, paclet:ref/NetModel])  ▪  (RefLink[TextCases, paclet:ref/TextCases])  ▪  (RefLink[TextSentences, paclet:ref/TextSentences])  ▪  (RefLink[WolframLanguageData, paclet:ref/WolframLanguageData])}, {Related Classifiers:  (RefLink[Sentiment, paclet:ref/classifier/Sentiment])  ▪  (RefLink[Spam, paclet:ref/classifier/Spam])  ▪  (RefLink[FacebookTopic, paclet:ref/classifier/FacebookTopic])}, {Related Machine Learning Methods:  (StringTypeLink[NaiveBayes, paclet:ref/method/NaiveBayes])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/22-machine-learning.html])(WebLink[: Machine Learning, https://www.wolfram.com/language/elementary-introduction/22-machine-learning.html])}, {(WebLink[DocumentationFooterIconsRelatedLinks-NeuralNetRepository.png(Spacer1)Wolfram Neural Net Repository, https://resources.wolframcloud.com/NeuralNetRepository/])}, {(Spacer1)▪(RefLinkPlain[(Spacer1)Machine Learning, paclet:guide/MachineLearning])}})}})