This API works on a sentence and tells us the profanity of the sentence in the form of Offensive or Non-offensive. Given a short sentence, it returns a label representing the identified profanity, along with a numeric confidence score.
https://api.textrics.ai/offensive_file_analysis.php
We support POST method to communicate with API.
1. dataset - This parameter is required
This is the upload file name which you wish to send to application to analyse.
2. api_key - This parameter is required
This is used to identify the user and the active subscription plan.
3. api_token - This parameter is required
This is used to authenticate the above user account.
4. language - This parameter is required
This is used to detect language of sentence in file.
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$cfile = new CURLFile( // input file containing text //
$_FILES['dataset']['tmp_name'],
$_FILES['dataset']['type'],
$_FILES['dataset']['name']
);
$apiUrl = 'https://api.textrics.ai/offensive_file_analysis.php'; // API URL //
$args['language'] = $_POST['language']; // Pass language used in file//
$args['dataset'] = $cfile; // pass uploaded file object //
$args['col_name'] = $_POST['col_name']; // Pass Column Name used in file//
$args['api_key'] = 'A32NBK55K3'; // user specific key to validate the account //
$args['api_token'] = 'P4lwpqT0YZYSVefSh44ADkvlJ8pesZDI'; // respective token to validate user credentials //
$options=[
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $args,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => ['Content-Type: multipart/form-data']
];
$ch = curl_init($apiUrl);
curl_setopt_array($ch, $options);
$response1 = curl_exec($ch);
echo $err = curl_error($ch);
curl_close($ch);
$response = json_decode($response1,true); // API output is stored in $response variable //
}
?>
if(!empty($response))
{
echo "<br/>";
echo "Response";
echo "<br/>";
echo "<pre style='text-align:left;'>";
print_r($response); // Printing the $response output on page //
echo "</pre>";
}
if(!empty($message))
{
echo $message;
}
?>
The response is structured in JSON as follows:
Array ( [response] => 1 [data] => Array ( [0] => Array ( [Sentence] => track record developing innovations valued market poor spend time talking previous wins innovations developed years ago decade ago opinions gatekeepers design value propositions pricing approach feature set committee prevalent highly collaborative blame culture eliminated individual accountability major project level [Prediction] => Non Abusive [Confidence] => 97.7685623169 [wordcloud] => Array ( [0] => track [1] => record [2] => developing [3] => innovations [4] => valued [5] => market [6] => poor. [7] => spend [8] => time [9] => talking [10] => previous [11] => wins [12] => (innovations [13] => developed [14] => years [15] => ago, [16] => decade [17] => ago). [18] => opinions [19] => / [20] => gatekeepers, [21] => design [22] => (of [23] => propositions, [24] => pricing [25] => approach [26] => feature [27] => set) [28] => committee [29] => prevalent. [30] => highly [31] => collaborative [32] => / [33] => "no [34] => blame" [35] => culture [36] => eliminated [37] => individual [38] => accountability [39] => major [40] => project [41] => level. ) ) [1] => Array ( [Sentence] => aware cost serve models developed believe gain valuable information spent time truly understanding direct costs customer type better direct human resources financial resources time energy [Prediction] => Non Abusive [Confidence] => 98.9111251831 [wordcloud] => Array ( [0] => not [1] => aware [2] => "cost [3] => serve" [4] => models [5] => developed; [6] => gain [7] => valuable [8] => information [9] => spent [10] => time [11] => understanding [12] => direct [13] => costs [14] => customer [15] => type [16] => direct [17] => human [18] => resources, [19] => financial [20] => resources, [21] => time [22] => energy. ) ) [2] => Array ( [Sentence] => significant weakness largescale production single family builders relative main facing competition moen hurts overall single family builder market particularly strong late [Prediction] => Non Abusive [Confidence] => 94.0337982178 [wordcloud] => Array ( [0] => significant [1] => weakness [2] => large-scale [3] => production [4] => single [5] => family [6] => builders, [7] => relative [8] => main [9] => facing [10] => competition [11] => - [12] => moen [13] => hurts [14] => single [15] => family [16] => builder [17] => market [18] => strong [19] => late. ) ) [3] => Array ( [Sentence] => areas improve understanding pro segment shops retail [Prediction] => Non Abusive [Confidence] => 91.0052566528 [wordcloud] => Array ( [0] => areas [1] => improve: [2] => understanding [3] => pro [4] => segment [5] => shops [6] => retail. ) ) [4] => Array ( [Sentence] => benefit cohesive company pricing strategy segments empowered decisions siloed result [Prediction] => Non Abusive [Confidence] => 94.71118927 [wordcloud] => Array ( [0] => benefit [1] => cohesive [2] => company [3] => pricing [4] => strategy. [5] => segments [6] => empowered [7] => make [8] => decisions, [9] => siloed [10] => result. ) ) [5] => Array ( [Sentence] => address customer segments effectively effectively bridge segments create channel conflict [Prediction] => Non Abusive [Confidence] => 95.0124664307 [wordcloud] => Array ( [0] => address [1] => customer [2] => segments [3] => effectively [4] => not [5] => effectively [6] => bridge [7] => segments [8] => create [9] => channel [10] => conflict. ) ) [6] => Array ( [Sentence] => believe look business segments develop strategies trade retail trade segments develop programs products trade market different hospitality urban high rise compared homeowner wants showroom personal space dont capabilities flexibility design team amazingly talented designing entire organization similarities design segment retail trade overlap particular [Prediction] => Non Abusive [Confidence] => 98.7848434448 [wordcloud] => Array ( [0] => business [1] => segments [2] => develop [3] => strategies [4] => trade [5] => retail. [6] => however, [7] => trade [8] => segments. [9] => develop [10] => programs [11] => products [12] => "all [13] => trade". [14] => market [15] => hospitality [16] => urban [17] => high [18] => rise [19] => compared [20] => homeowner [21] => showroom [22] => personal [23] => space. [24] => capabilities [25] => flexibility. [26] => design [27] => team [28] => amazingly [29] => talented [30] => designing [31] => entire [32] => organization [33] => similarities [34] => design [35] => segment [36] => (retail [37] => trade [38] => overlap [39] => particular) ) ) [7] => Array ( [Sentence] => challenge times depth view customer views [Prediction] => Non Abusive [Confidence] => 92.7763900757 [wordcloud] => Array ( [0] => challenge [1] => times [2] => depth [3] => view [4] => customer [5] => views. ) ) [8] => Array ( [Sentence] => challenge overlapping brands competing business times driving decision pricein essence commoditizing products efforts field creating mashup brands diluting value brings customer [Prediction] => Non Abusive [Confidence] => 98.5059051514 [wordcloud] => Array ( [0] => challenge [1] => overlapping [2] => brands [3] => competing [4] => business, [5] => times, [6] => driving [7] => decision [8] => price...in [9] => essence, [10] => commoditizing [11] => products. [12] => efforts [13] => field [14] => creating [15] => mash-up [16] => brands, [17] => diluting [18] => brings [19] => customer. ) ) ) [message] => success )
Code | Interpretation |
---|---|
1 | Success |
Exception Codes | |
10 | Authentication Exception |
11 | Invalid Input Exception |
12 | Language Exception |
13 | File Format Error |
14 | Request Timeout |
15 | Column Name Mismatch |
99 | Other Exception |