PHP code example of nv / semtools

1. Go to this page and download the library: Download nv/semtools library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nv / semtools example snippets


use nv\semtools\Classifiers\uClassify;

header('Content-type: text/xml');

// Instantiate the reader with your API key (provided by uClassify)
$classifier = new uClassify\UclassifyReader('YOUR_API_KEY');

// Create a new request with the text to be classified and the classifier to use
$classifierRequest = new uClassify\UclassifyRequest(
    'My happy text',
    'prfekt/Myers Briggs Attitude'
);

// Execute and return the request
$classifierResponse = $classifier->read($classifierRequest);
echo $classifierResponse->getResponse();

use nv\semtools\Annotators\OpenCalais;

// The content to process
$content = '';
// Instantiate a new annotator instance with your API key (provided by OpenCalais)
$annotator = new OpenCalais\OpenCalaisReader('YOUR_API_KEY');

// Create a new request with passing the content as parameter
$annotatorRequest = new OpenCalais\OpenCalaisRequest($content);

// Execute request, recieve response
$annotatorResponse = $annotator->read($annotatorRequest);

// To get the raw response
$annotatorResponse->getResponse();

// To get the response parsed to php array
print_r($annotatorResponse->getEntities());

...