Repo for the search and displace core module including the interface to select files and search and displace operations to run on them. https://searchanddisplace.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 lines
917 B

<?php
namespace App\SearchDisplace\Searchers;
use GuzzleHttp\Client;
class Duckling
{
protected $url;
public function __construct()
{
$this->url = env('SD_DUCKLING_URL');
// $this->url = 'host.docker.internal:5000/parse';
}
public function execute($content, $dimensions)
{
// @TODO Parse result
return $this->sendRequest($content, $dimensions);
}
protected function sendRequest($text, $dimensions)
{
$client = new Client();
$response = $client->request('post', $this->url, [
'headers' => [
'Accept' => 'application/json',
],
'form_params' => [
'locale' => 'en_GB',
'text' => $text,
'dims' => json_encode($dimensions),
],
]);
return json_decode($response->getBody()->getContents(), true);
}
}