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

  1. <?php
  2. namespace App\SearchDisplace\Searchers;
  3. use GuzzleHttp\Client;
  4. class Duckling
  5. {
  6. protected $url;
  7. public function __construct()
  8. {
  9. // $this->url = env('SD_DUCKLING_URL');
  10. $this->url = 'host.docker.internal:5000/parse';
  11. }
  12. public function execute($content, $dimensions)
  13. {
  14. // @TODO Parse result
  15. return $this->sendRequest($content, $dimensions);
  16. }
  17. protected function sendRequest($text, $dimensions)
  18. {
  19. $client = new Client();
  20. $response = $client->request('post', $this->url, [
  21. 'headers' => [
  22. 'Accept' => 'application/json',
  23. ],
  24. 'form_params' => [
  25. 'locale' => 'en_GB',
  26. 'text' => $text,
  27. 'dims' => json_encode($dimensions),
  28. ],
  29. ]);
  30. return json_decode($response->getBody()->getContents(), true);
  31. }
  32. }