Class: ProfanityService

ProfanityService()

This module detects profanities and the level of offensiveness in a body of text.

Constructor

new ProfanityService()

Source:

Methods

call(user, text) → {Promise.<Object>}

Parameters:
Name Type Description
user string The ID of the user accessing the Soffos API. Soffos assumes that the owner of the api is an application (app) and that app has users. Soffos API will accept any string.
text string Input text.
Source:
Returns:
offensive_probability - float
A float value between 0 and 1 indicating the degree of offensiveness.
offensive_prediction - boolean
Boolean value indicating whether the probability exceeds the threshold of what is definitely considered offensive for the underlying model.
profanities - dictionary list
List of dictionaries resembling detected profanities. Each dictionary contains the following fields:
text: The text of the profanity.
span_start: The starting character index of the profanity in the original text.
span_end: The ending character index of the profanity in the original text.
Type
Promise.<Object>
Example
import { SoffosServices } from "soffosai";

const my_apiKey = "Token <put your api key here>";
const service = new SoffosServices.ProfanityService({apiKey:my_apiKey});
let response = await service.call("client123", "Don't give me this shit.");
console.log(JSON.stringify(response, null, 2));
    
// returns
// {
//     "profanities": [
//       {
//         "text": "shit",
//         "span_start": 19,
//         "span_end": 23
//       }
//     ],
//     "offensive_probability": 0.8668110370635986,
//     "offensive_prediction": true,
//     "cost": {
//       "api_call_cost": 0.005,
//       "character_volume_cost": 0.005,
//       "total_cost": 0.01
//     },
//     "charged_character_count": 100,
//     "unit_price": "0.000050"
// }

setInputConfigs(name, text)

Parameters:
Name Type Description
name string Reference name of this Service. It will be used by the Pipeline to reference this Service.
text string | InputConfig Input text.
Source: