PHP code example of ahmedash95 / sentimento

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

    

ahmedash95 / sentimento example snippets


use Ahmedash95\Sentimento\Facade\Sentimento;

$result = Sentimento::analyze("Food was great!");

$result->value; // Positive

use Ahmedash95\Sentimento\Facade\Sentimento;

Sentimento::analyze("Food was great!"); // Positive

Sentimento::analyze("Food was bad!"); // Negative

Sentimento::analyze("لما اتصلت بالدليفري قالي انه اكل الاوردر"); // Negative

use Ahmedash95\Sentimento\Facade\Sentimento;
use Illuminate\Http\Client\RequestException;

try {
    $result = Sentimento::analyze("Food was great!");
} catch (RequestException $e) {
    // $e->getMessage()
}

// instead of exception, the result will be Decision::Unknown

$result = Sentimento::analyze("Food was great!"); // Unknown
bash
php artisan vendor:publish --tag="sentimento-config"