PHP code example of christopherarter / dream

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

    

christopherarter / dream example snippets


use Dream\Facades\Dream;

use Dream\Facades\Dream;

$sentiment = Dream::text('I love Laravel!')->sentiment();
$sentiment->disposition(); // 'positive';
$sentiment->positive(); // true;

use Dream\Facades\Dream;

$sentiment->disposition(); // 'positive' | 'negative' | 'neutral';
$sentiment->positive(); // true | false;
$sentiment->negative(); // true | false;
$sentiment->neutral(); // true | false;

use Dream\Facades\Dream;

$entities = Dream::text('I need a reservation for Mr. Foo and Mr. Bar at 
the Foo Bar Restaurant on October 31st.')
->entities();

$entities->people()->toArray(); // ['Mr. Foo', 'Mr. Bar'];
$entities->places()->toArray(); // ['Foo Bar Restaurant'];
$entities->dates()->toArray(); // ['October 31st'];

$entities->people(); // Collection of people
$entities->places(); // Collection of places
$entities->dates(); // Collection of dates
$entities->organizations(); // Collection of organizations
$entities->events(); // Collection of events
$entities->products(); // Collection of products
$entities->quantities(); // Collection of quantities
$enteties->other(); // Collection of other entities

use Dream\Facades\Dream;

Dream::text('Laravel is a web application framework with expressive, 
elegant syntax. We’ve already laid the foundation — freeing you to create 
without sweating the small things.')
  ->phrases()
  ->pluck('text')
  ->toArray();
  
// [
//   "Laravel",
//   "a web application framework",
//   "expressive, elegant syntax",
//   "the foundation —",
//   "the small things",
// ]

use Dream\Facades\Dream;

Dream::text('¿Cuál es tu película favorita?')->language(); // 'es'

use Dream\Facades\Dream;

$file = Storage::get('image.jpg');
Dream::image($file)
    ->text()
    ->pluck('text')
    ->toArray();
    
// ["This was text in an image"]

use Dream\Facades\Dream;

$file = Storage::get('image.jpg');
Dream::image($file)
    ->labels()
    ->pluck('name')
    ->toArray();
    
// ["man", "fish", "boat", "water", "ocean", "sea"];



use Dream\Clients\Client;
use Dream\Collections\TextEntityCollection;
use Illuminate\Support\Collection

class MyCustomClient extends Client
{
    public function text(string $text): MyCustomTextClient
    {
        return new MyCustomTextClient($text);
    }
    
    public function image(string $image): MyCustomImageClient
    {
        return new MyCustomImageClient($image);
    }
}



return [
    'connections' => [
        // ...
        'my-custom-client' => [
            'driver' => MyCustomClient::class,
        ],   
    ],
];
bash
php artisan vendor:publish --provider="Dream\DreamServiceProvider"