I needed a Hunspell wrapper for PHP yesterday, as we’re looking at replacing the Google Spellchecking API with a hosted solution. After a bit of searching on Google I couldn’t find one that fitted the needs of our current project.
So i’ve created a simple one (fork on github).
It supports input & output in UTF-8 (as we’re using this for parsing Arabic), and can output in two modes:
- a standard PHP array keyed on the misspelled word, or
- It can mimic the Google Spellchecking API, which means it can be a direct drop-in replacement for this service.
The second method is useful for us, as it means we can simply redirect the spellchecking endpoints and get the new hosted solution without changing any parsing code.
Dear Sebastian, Please give me some example how to use. Thank you.
Usage is as follows (include the file first):
$input = “example bad speeling”;
$spell = new hunspell($input);
echo $spell->getGoogleFormatted();
or if you just want the array:
$spell->get();