HS Banner
Back
PHP Speller

Author: Admin 03/26/2023
Language: PHP
Tags: php spell check


Description:

PHP spell check library.

Article:

Currently supported backends:

Usage

  1. Create a text source object from string, file or something else using one of the Mekras\Speller\Source\Source implementations (see Sources below).
  2. Create some speller instance (Hunspell, Ispell or any other implementation of the Mekras\Speller\Speller).
  3. Execute 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


Back
Comments
Add Comment
There are no comments yet.