PHP code example of codeconjure / php-hunspell

1. Go to this page and download the library: Download codeconjure/php-hunspell 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/ */

    

codeconjure / php-hunspell example snippets



$dict = new Hunspell\Dictionary('/path/to/hu_HU.aff', '/path/to/hu_HU.dic');

$dict->spell('szótár');                   // bool
$dict->suggest('szóter');                 // list<string>
$dict->stem('szótárak');                  // list<string>
$dict->analyze('szótárak');               // list<Hunspell\Analysis>

$a = $dict->analyze('szótárak')[0];
$a->getRaw();                             // raw morph string
$a->getFields();                          // array<string, list<string>>
$a->get('st');                            // stems (list<string>)
$a->has('hy');                            // bool — does this analysis carry a hyphenation hint?

$dict->generate('ház', 'kertben');        // generate form of ház matching kertben's morphology
$dict->addWithAffix('Németh', 'világ');   // proper noun inherits világ's affix flags

try {
    $dict = new Hunspell\Dictionary($aff, $dic);
} catch (Hunspell\Exception\Exception $e) {
    // Any Hunspell-layer failure (currently only DictionaryLoadException)
}
sh
pie install codeconjure/php-hunspell
sh
git clone https://github.com/connorhu/php-hunspell.git
cd php-hunspell
phpize
./configure --enable-hunspell
make
sudo make install
echo "extension=hunspell.so" | sudo tee /etc/php/conf.d/hunspell.ini