Detect profanities

Detect

The detectProfanities service provides automated identification and flagging of profane or offensive language within a given text string. Operating as a standalone service, it allows for content moderation independently of the translation workflow.

The service analyzes the submitted text to detect sensitive content and returns a structured response including the detected language and content type. This endpoint is designed to help developers maintain platform safety by programmatically identifying potentially inappropriate strings before they are processed or displayed.

Request

res = lara.detectProfanities("Don't be such a tool!",
                     language='en-US',
                     content_type='text/plain'
                   )

print(res)
const res  = await lara.detectProfanities("Don't be such a tool!", 'en-US', 'text/plain');
                                             
console.log(res);
DetectResult res = lara.detectProfanities("Don't be such a tool!", 'en-US', 'text/plain');
$res = $lara->detectProfanities("Don't be such a tool!", 'en-US', 'text/plain');
res, _ := lara.detectProfanities("Don't be such a tool!", 'en-US', 'text/plain')

fmt.Println(*res.String)
val res: DetectProfanitiesResult = lara.detectProfanities("Don't be such a tool!", 'en-US', 'text/plain')
var res = await lara.detectProfanities("Don't be such a tool!", 'en-US', 'text/plain');
let res = try await lara.detectProfanities(text: "Don't be such a tool!", language: "en", content_type: "text/plain")

Here follows the basic fields for the detect method:

Field

Type

Required

Default

Description

text

String

Yes


The text to be detected. This can be a single string.

language

String

No


The source language code (e.g., "en-US" for English).

content_type

String

No


The content type.

The result of the detect method is an object containing:

FieldTypeDescription
maskedTextStringThe masked text
profanitiesString[]The detected profanities object

Response

Result: {
  "maskedText": "Don't be s**h a tool!",
  "profanities": [
    {
      "text": "such",
      "startCharIndex": 9,
      "endCharIndex": 16,
      "score": 0.8136
    }
  ]
}

Billing

More details are available in the pricing page