Last active
December 19, 2016 12:07
-
-
Save cereal-s/205c1f2220fb3c921673a47caf813b33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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