Last active
December 19, 2016 12:15
-
-
Save cereal-s/434e2b61e518a182fbae2e18fe9c2f2a 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
hello | |
world | |
apple | |
fruit | |
banana | |
yellow | |
orange | |
strawberry | |
cherry | |
pie |
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 | |
$r = enchant_broker_init(); | |
$mydict = 'dict.pwl'; # word list: 1 word for each line | |
$word = 'appl'; # word to check | |
$result = array(); | |
//$d = enchant_broker_request_pwl_dict($r,$mydict); | |
$d = enchant_broker_request_dict($r,'en_GB'); # load standard dictionary | |
$dict_details = enchant_dict_describe($d); | |
$dprovides = enchant_dict_describe($d); | |
echo "dictionary provides:\n"; | |
$wordcorrect = enchant_dict_check($d, $word); | |
print_r($dprovides); # details about the loaded dictionary | |
if( ! $wordcorrect) | |
{ | |
$suggestions = enchant_dict_suggest($d, $word); | |
foreach($suggestions as $suggestion) | |
{ | |
similar_text($word, $suggestion, $percent); | |
if (round($percent) > 70) | |
$result[] = $suggestion; | |
} | |
} | |
//$result = array_unique($result); # no duplicates | |
print_r($result); | |
enchant_broker_free_dict($d); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment