Author: Admin 03/26/2023
Language:
PHP
Tags: php spell check
PHP spell check library.
Currently supported backends:
Mekras\Speller\Source\Source
implementations (see Sources below).Mekras\Speller\Speller
).Speller::checkText()
method.use Mekras\Speller\Hunspell\Hunspell;
use Mekras\Speller\Source\StringSource;
$source = new StringSource('Tiger, tigr, burning bright');
$speller = new Hunspell();
$issues = $speller->checkText($source, ['en_GB', 'en']);
echo $issues[0]->word; // -> "tigr"
echo $issues[0]->line; // -> 1
echo $issues[0]->offset; // -> 7
echo implode(',', $issues[0]->suggestions); // -> tiger, trig, tier, tigris, tigress
You can list languages supported by backend:
/** @var Mekras\Speller\Speller $speller */
print_r($speller->getSupportedLanguages());
Read more at GitHub - mekras/php-speller: PHP spell check library