ProfanityAnalyzer

public class ProfanityAnalyzer

Class to analyze a text for hate speech content.

It is a good idea to test that the model is loaded before calling analyze(). A simple use-case to test a text for hate speech would be:

func classifyText(text: String) -> Bool {
    if (ProfanityAnalyzer.sharedInstance().isLoaded()) {
        return ProfanityAnalyzer.sharedInstance().containsProfanity(text: text)
    }
    return false
}
  • Class function to get the single instance of this class.

    Declaration

    Swift

    public static func sharedInstance() -> ProfanityAnalyzer

    Return Value

    The singleton instance of the class.

  • Initialise the profanity analyzer.

    Declaration

    Swift

    public func initManager()
  • Analyze a text for profanity.

    Declaration

    Swift

    public func containsProfanity(text: String) -> Bool

    Parameters

    text

    The text to analyze.

    Return Value

    true if the text contains profanity, false otherwise.