This API works on a sentence and given us extracts abstract "topics" from text based on the frequency of the particular terms used. . This organizing and extracting information from large chunks of unstructured text can be pretty time-consuming
https://api.textrics.ai/topic_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/topic_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 ( [columns] => Array ( [0] => Word 0 [1] => Word 1 [2] => Word 2 [3] => Word 3 [4] => Word 4 [5] => Word 5 [6] => Word 6 [7] => Word 7 [8] => Word 8 [9] => Word 9 ) [index] => Array ( [0] => Topic 0 [1] => Topic 1 [2] => Topic 2 [3] => Topic 3 [4] => Topic 4 [5] => Topic 5 [6] => Topic 6 [7] => Topic 7 [8] => Topic 8 [9] => Topic 9 ) [data] => Array ( [0] => Array ( [0] => single [1] => family [2] => large [3] => face [4] => builder [5] => relative [6] => overall [7] => particularly [8] => builders [9] => hurt ) [1] => Array ( [0] => segment [1] => price [2] => empower [3] => siloed [4] => strategy [5] => cohesive [6] => company [7] => decision [8] => result [9] => benefit ) [2] => Array ( [0] => segment [1] => effectively [2] => create [3] => channel [4] => address [5] => customer [6] => conflict [7] => bridge [8] => blame [9] => large ) [3] => Array ( [0] => time [1] => direct [2] => resource [3] => cost [4] => customer [5] => view [6] => valuable [7] => develope [8] => information [9] => believe ) [4] => Array ( [0] => trade [1] => design [2] => segment [3] => develop [4] => retail [5] => rise [6] => particular [7] => believe [8] => urban [9] => different ) [5] => Array ( [0] => address [1] => effort [2] => project [3] => conflict [4] => blame [5] => field [6] => gatekeeper [7] => areas [8] => channel [9] => competition ) [6] => Array ( [0] => segment [1] => effectively [2] => address [3] => channel [4] => bridge [5] => create [6] => customer [7] => shop [8] => retail [9] => improve ) [7] => Array ( [0] => value [1] => develope [2] => innovation [3] => ago [4] => price [5] => time [6] => brand [7] => accountability [8] => market [9] => win ) [8] => Array ( [0] => view [1] => customer [2] => program [3] => decade [4] => time [5] => year [6] => depth [7] => serve [8] => commoditizing [9] => effectively ) [9] => Array ( [0] => shop [1] => retail [2] => segment [3] => improve [4] => understand [5] => areas [6] => pro [7] => spend [8] => talk [9] => decade ) ) ) [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 |