1. Go to this page and download the library: Download aflorea4/laravel-nlp 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/ */
aflorea4 / laravel-nlp example snippets
use Web64\LaravelNlp\Facades\NLP;
// Get Article content and metadata
$article = NLP::article($url);
// Detect language
$lang = NLP::language("What language is this?");
// Entity Extraction
$entities = NLP::entities( $text, 'en' );
// Sentiment analysis
$sentiment = NLP::sentiment( $text, 'en' );
// Translage text to Portuguese
$translated_text = NLP::translate($text, null, 'pt');
use Web64\LaravelNlp\Facades\NLP;
$lang = NLP::language("What language is this?");
// 'en'
$text = "Barack Hussein Obama is an American politician who served as the 44th President of the United States from January 20, 2009 to January 20, 2017. Before that, he served in the Illinois State Senate from 1997 until 2004.";
$entities = NLP::entities( $text, 'en' );
/*
Array
(
[0] => Barack Hussein Obama
[1] => American
[2] => United States
[3] => Illinois
)
*/
$translated_text = NLP::translate($text, $from_lang, $to_lang);
$translated_text = NLP::translate("Mange er opprørt etter avsløringene om at persondata for 87 millioner Facebook-brukere skal være på avveie", null, 'pt');
// 'Muitas pessoas estão chateadas após a divulgação de que os dados pessoais de 87 milhões de usuários do Facebook devem estar fora de ordem'