Skip to content

Instantly share code, notes, and snippets.

@cereal-s
Last active December 19, 2016 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cereal-s/205c1f2220fb3c921673a47caf813b33 to your computer and use it in GitHub Desktop.
Save cereal-s/205c1f2220fb3c921673a47caf813b33 to your computer and use it in GitHub Desktop.
<?php
$word = 'scmo';
$pspell_config = pspell_config_create("it");
# Available modes:
#
# PSPELL_FAST
# PSPELL_NORMAL
# PSPELL_BAD_SPELLERS # this will slow down the script
#
pspell_config_mode($pspell_config, PSPELL_BAD_SPELLERS);
$pspell_link = pspell_new_config($pspell_config);
$result = array();
if( ! pspell_check($pspell_link, $word))
{
$suggestions = pspell_suggest($pspell_link, $word);
foreach($suggestions as $suggestion)
{
similar_text($word, $suggestion, $percent);
if(round($percent) > 85)
$result[] = $suggestion;
}
}
$result = array_unique($result); # no duplicates
print_r($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment