Skip to content

Instantly share code, notes, and snippets.

@cereal-s
Last active December 19, 2016 12:15
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/434e2b61e518a182fbae2e18fe9c2f2a to your computer and use it in GitHub Desktop.
Save cereal-s/434e2b61e518a182fbae2e18fe9c2f2a to your computer and use it in GitHub Desktop.
hello
world
apple
fruit
banana
yellow
orange
strawberry
cherry
pie
<?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