Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.
/ yandex-speller Public archive

Laravel wrapper package for the Yandex Speller API

License

Notifications You must be signed in to change notification settings

fecony/yandex-speller

Repository files navigation

Laravel Yandex Speller API Wrapper

Latest Version on Packagist Total Downloads Build Status Codecov Scrutinizer Code Quality Style CI

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...


Installation

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

Basic Usage

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.

Facade:

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);
}

Helper function:

public function index()
{
    $result = speller('Helllo world!');
    // Do whatever you want with results
    // $this->someService->swapWords($result->getData()->data);
}

Advanced usage

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.

Configuration

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

Testing

composer test

Roadmap

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...

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Laravel wrapper package for the Yandex Speller API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages