fecony / yandex-speller
此包已被废弃且不再维护。未建议替代包。
Laravel 对 Yandex Speller API 的包装器
v1.0.0
2020-12-23 15:22 UTC
Requires
- php: >=7.3
- ext-json: *
- guzzlehttp/guzzle: ^7.2
- illuminate/support: ^8.19
Requires (Dev)
- orchestra/testbench: ^6.7
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-master
- sempro/phpunit-pretty-print: ^1.3
README
简单的 Laravel Yandex Speller API 响应包装器。
遗憾的是,Yandex Speller 现在不再官方支持 🙁
基本的拼写检查功能正常工作,但选项对 API 工作没有影响...
安装
您可以通过 composer 安装此包
composer require fecony/yandex-speller
您可以发布包配置文件
php artisan vendor:publish --tag=yandex-speller
基本用法
使用此包有两种方式:使用外观或使用辅助函数。无论哪种方式,您都会得到相同的结果,完全取决于您。
外观
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); }
高级用法
YandexSpeller::check()
方法和 speller()
辅助函数都接受四个参数
string | array $text
要检查的文本字符串或字符串数组。string | null $lang
用于重写配置中定义的 $lang 参数,逗号分隔的语言,可选。int | null $options
用于重写配置中定义的 $options 参数,可能的选项之和,可选。string | null $format
用于重写配置中定义的 $format 参数,'plain' 或 'html',可选。
配置
如果您需要自定义默认配置,可以直接在 yandex-speller.php
配置文件中操作。
选项 | 默认 | 描述 |
---|---|---|
lang | 'ru,en' | 此选项指定要检查的文本的默认语言。参数值应为逗号分隔。 |
format | 'plain' | 此选项指定要检查的文本的默认格式。 |
options | 0 | 此选项指定 API 的行为。参数值是选项值的总和。请参阅:https://yandex.ru/dev/speller/doc/dg/reference/speller-options.html |
测试
composer test
路线图
此包是一个基本的包装器,用于调用 Yandex Speller API,您可以使用 Yandex Speller 支持的所有参数。如果您发现有趣的用例,可能会添加新功能。
例如
- 将结果包装起来用于其他方法。
- 返回应用了建议的文本。
- 等等...
变更日志
请参阅 CHANGELOG 以获取有关最近更改的更多信息。
贡献
请参阅CONTRIBUTING以获取详细信息。
致谢
许可
MIT许可(MIT)。请参阅许可文件以获取更多信息。