SunshinePHP 2016


Ejemplo #1 Ejemplos de Uso de Enchant

$r enchant_broker_init();
$bprovides enchant_broker_describe($r);
"El agente actual proporciona los siguientes entornos:\n";

$diccionarios enchant_broker_list_dicts($r);
if (
enchant_broker_dict_exists($r,$etiqueta)) {
$d enchant_broker_request_dict($r$etiqueta);
$dprovides enchant_dict_describe($d);
"el diccionario $etiqueta proporciona:\n";
$palabra_correcta enchant_dict_check($d"soong");
    if (!
$palabra_correcta) {
$sugerencias enchant_dict_suggest($d"soong");
"Sugerencias para 'soong':";
} else {
add a note add a note

User Contributed Notes 3 notes

robert dot johnson at icap dot com
3 years ago
Here is help for Windows users:

You need to add dictionaries to your computer for Enchant.

1. Enchant looks in your registry keys, I don't know what keys it wants, but it looks here - I ignored all of these:
  * Default User\Software\Enchant\Config
  * Default User\Software\Enchant\Ispell
  * Default User\Software\Enchant\Myspell
2. It looks for OpenOffice dictionaries (from the registry settings for OpenOffice)
3. It looks in folder [PHP]\share\myspell\dicts

I got it working by copying the en-us dictionary files from Firefox into \share\myspell\dicts, and renaming them en_US.*.  You can download and install dictionaries from OpenOffice from here I think:

Enchant creates and writes to the following folder, so you must allow PHP read and write permissions to: [SYSTEM32]\config\systemprofile\Application Data\enchant

It would be convenient if Enchant could accept parameters to specify the location of the main dictionaries and user-dictionaries, I suppose the registry keys are the only way to do it.
2 years ago
One thing to add to robert.johnson's very helpful post, I found that the dictionary files (*.dic and *.aff) could only contain A-Z and _ characters or they wouldn't be listed in the output of enchant_broker_list_dicts() (at least for PHP 5.4 / Windows).

This was an issue when downloading some of the dictionary files from where the file names contained hyphens, pt-BR for example. Just replace the hyphen with an underscore in the file name and enchant recognises the language code.
robert dot johnson at icap dot com
2 years ago
To repeat a note by  wschalle at gmail dot com on page

The enchant library does not work unless libenchant_myspell.dll and libenchant_ispell.dll are placed in [PHP]\lib\enchant from PHP 5.4.13.

Dictionaries will still load from [PHP]\share\myspell\dicts.
To Top