PHP code example of nlpcloud / nlpcloud-client

1. Go to this page and download the library: Download nlpcloud/nlpcloud-client 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/ */

    

nlpcloud / nlpcloud-client example snippets




use NLPCloud\NLPCloud;

$client = new NLPCloud('bart-large-cnn', '<your token>');
echo json_encode($client->summarization('One month after the United States began what has become a 
  troubled rollout of a national COVID vaccination campaign, the effort is finally 
  gathering real steam. Close to a million doses -- over 951,000, to be more exact -- 
  made their way into the arms of Americans in the past 24 hours, the U.S. Centers 
  for Disease Control and Prevention reported Wednesday. That s the largest number 
  of shots given in one day since the rollout began and a big jump from the 
  previous day, when just under 340,000 doses were given, CBS News reported. 
  That number is likely to jump quickly after the federal government on Tuesday 
  gave states the OK to vaccinate anyone over 65 and said it would release all 
  the doses of vaccine it has available for distribution. Meanwhile, a number 
  of states have now opened mass vaccination sites in an effort to get larger 
  numbers of people inoculated, CBS News reported.'));



use NLPCloud\NLPCloud;

$client = new NLPCloud('bart-large-cnn', '<your token>', True);
echo json_encode($client->summarization('One month after the United States began what has become a 
  troubled rollout of a national COVID vaccination campaign, the effort is finally 
  gathering real steam. Close to a million doses -- over 951,000, to be more exact -- 
  made their way into the arms of Americans in the past 24 hours, the U.S. Centers 
  for Disease Control and Prevention reported Wednesday. That s the largest number 
  of shots given in one day since the rollout began and a big jump from the 
  previous day, when just under 340,000 doses were given, CBS News reported. 
  That number is likely to jump quickly after the federal government on Tuesday 
  gave states the OK to vaccinate anyone over 65 and said it would release all 
  the doses of vaccine it has available for distribution. Meanwhile, a number 
  of states have now opened mass vaccination sites in an effort to get larger 
  numbers of people inoculated, CBS News reported.'));



use NLPCloud\NLPCloud;

$client = new NLPCloud('bart-large-cnn', '<your token>', True, 'fra_Latn');
echo json_encode($client->summarization('Sur des images aériennes, prises la veille par un vol de surveillance 
  de la Nouvelle-Zélande, la côte d’une île est bordée d’arbres passés du vert 
  au gris sous l’effet des retombées volcaniques. On y voit aussi des immeubles
  endommagés côtoyer des bâtiments intacts. « D’après le peu d’informations
  dont nous disposons, l’échelle de la dévastation pourrait être immense, 
  spécialement pour les îles les plus isolées », avait déclaré plus tôt 
  Katie Greenwood, de la Fédération internationale des sociétés de la Croix-Rouge.
  Selon l’Organisation mondiale de la santé (OMS), une centaine de maisons ont
  été endommagées, dont cinquante ont été détruites sur l’île principale de
  Tonga, Tongatapu. La police locale, citée par les autorités néo-zélandaises,
  a également fait état de deux morts, dont une Britannique âgée de 50 ans,
  Angela Glover, emportée par le tsunami après avoir essayé de sauver les chiens
  de son refuge, selon sa famille.'));

use NLPCloud\NLPCloud;

$client = new NLPCloud('<model>','<your token>');

use NLPCloud\NLPCloud;

$client = new NLPCloud('<model>','<your token>', true);

use NLPCloud\NLPCloud;

$client = new NLPCloud('<model>','<your token>', false, '<your language code>');

use NLPCloud\NLPCloud;

$client = new NLPCloud('<model>', '<your token>', false, '<your language code>', true);

$client->asyncResult('https://api.nlpcloud.io/v1/get-async-result/21718218-42e8-4be9-a67f-b7e18e03b436');

echo json_encode($client->asr('<Your url>'));

echo json_encode($client->chatbot('<Your input>', '<Your context>', array(array('input'=>'input 1','response'=>'response 1'), array('input'=>'input 2','response'=>'response 2'), ...)));

echo json_encode($client->classification('<Your block of text>', array('label 1', 'label 2', ...), True|False));

echo json_encode($client->codeGeneration('<Your instruction>'));

echo json_encode($client->dependencies('<Your block of text>'));

echo json_encode($client->embeddings(array('<Text 1>', '<Text 2>', '<Text 3>', ...)));

echo json_encode($client->entities('<Your block of text>'));

echo json_encode($client->generation('<Your input text>'));

echo json_encode($client->gsCorrection('<Your block of text>'));

echo json_encode($client->imageGeneration('<Your block of text>'));

echo json_encode($client->intentClassification('<Your block of text>'));

echo json_encode($client->kwKpExtraction('<Your block of text>'));

echo json_encode($client->langdetection('<Text to analyze>'));

echo json_encode($client->paraphrasing('<Your text to paraphrase>'));

echo json_encode($client->question('<Your question>','<Your context>'));

echo json_encode($client->semanticSearch('<Your search query>'));

echo json_encode($client->semanticSimilarity(array('<Block of text 1>', '<Block of text 2>')));

echo json_encode($client->sentenceDependencies('<Your block of text>'));

echo json_encode($client->sentiment('<Your block of text>', '<Your target element>'));

echo json_encode($client->speechSynthesis('<Your block of text>'));

echo json_encode($client->summarization('<Your text to summarize>'));

echo json_encode($client->tokens('<Your block of text>'));

echo json_encode($client->translation('<Your text to translate>'));