Simple Laravel Yandex Speller API response wrapper.
Unfortunately Yandex Speller is not supported officially now 🙁
Basic spellchecking is working, but options have no effect on API work...
You can install the package via composer:
composer require fecony/yandex-speller
You can publish the package config file
php artisan vendor:publish --tag=yandex-speller
There are to ways of utilizing the package: using the facade, or using the helper function. On either way you will get the same result, it is totally up to you.
use Fecony\YandexSpeller\Facade\YandexSpeller;
...
public function index()
{
$result = YandexSpeller::check('Helllo world!');
// Do whatever you want with results
// $this->someService->swapWords($result->getData()->data);
}
public function index()
{
$result = speller('Helllo world!');
// Do whatever you want with results
// $this->someService->swapWords($result->getData()->data);
}
Both YandexSpeller::check()
method and speller()
helper accept four parameters:
string | array $text
text sting or array of strings to check spelling.string | null $lang
used to rewrite config defined $lang parameter, comma separated languages, optional.int | null $options
used to rewrite config defined $options parameter, sum of possible options, optional.string | null $format
used to rewrite config defined $format parameter, 'plain' or 'html', optional.
If you need to customize the default config, you can do it directly on the yandex-speller.php
configuration file.
option | default | description |
---|---|---|
lang | 'ru,en' | This option specifies the default languages of the text to be checked. The parameter value should be comma separated. |
format | 'plain' | This option specifies the default format of the text to be checked. |
options | 0 | This option specifies the behaviour of the API. The parameter value is the sum of the option values. Refer to: https://yandex.ru/dev/speller/doc/dg/reference/speller-options.html |
composer test
This package is basic wrapper to make call to Yandex Speller API, it is possible to use any parameters that Yandex Speller is supporting for now. New Features may be made in case you find interesting use cases.
For example:
- Wrap result to use in other methods.
- Return text with suggestions applied.
- etc...
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.