PHP code example of chr15k / php-spelling

1. Go to this page and download the library: Download chr15k/php-spelling library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

chr15k / php-spelling example snippets




use \Chr15k\Spelling\Spelling;

$spelling = new Spelling('en'); // default is 'en'

echo $spelling->check('tree'); // true
echo $spelling->check('treezzz'); // false



use \Chr15k\Spelling\Spelling;

$spelling = new Spelling('en'); // default is 'en'

print_r($spelling->suggestions('specifecally'));
/*
    (
        [0] => specifically
        [1] => pacifically
        [2] => soporifically
        [3] => specifiable
        [4] => specifics
        [5] => specific
        [6] => specific's
    )
*/



use \Chr15k\Spelling\Spelling;

$spelling = new Spelling('en'); // default is 'en'

echo $spelling->autoSuggestion('specifecally'); // specifically
echo $spelling->autoSuggestion('specifecally?'); // specifically?
echo $spelling->autoSuggestion('weeird'); // weird
echo $spelling->autoSuggestion('weeird!'); // weird!



use \Chr15k\Spelling\Spelling;

$spelling = new Spelling('en'); // default is 'en'

echo $spelling->autoCorrection('He is in his ooffice.'); // He is in his office.
echo $spelling->autoCorrection('He sat underr a tree.'); // He sat under a tree.
echo $spelling->autoCorrection('Thereg is someone at the door.'); // There is someone at the door.
bash
composer