PHP code example of darrynten / google-natural-language-php

1. Go to this page and download the library: Download darrynten/google-natural-language-php 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/ */

    

darrynten / google-natural-language-php example snippets


use DarrynTen\GoogleNaturalLanguagePhp\GoogleNaturalLanguage;

// Config options
$config = [
  'projectId' => 'my-awesome-project'  // At the very least
];

// Make a processor
$language = new GoogleNaturalLanguage($config);

// Set text
$text = 'Google Natural Language processing is awesome!';
$language->setText($text);

// Get stuff
$language->getEntities();
$language->getSyntax();
$language->getSentiment();

// Get all stuff
$language->getAll();

// Set optional things
$language->setType('HTML');
$language->setLanguage('en');
$language->setEncodingType('UTF16');

// Extra features
$language->setCaching(false);
$language->setCheapskate(false);

// Full config options
$config = [
  'projectId' => 'my-awesome-project',     //