pspell_config_create

(PHP 4 >= 4.0.2, PHP 5, PHP 7, PHP 8)

pspell_config_createCrear una configuración usada para abrir un diccionario

Descripción

pspell_config_create(
    string $language,
    string $spelling = ?,
    string $jargon = ?,
    string $encoding = ?
): int

Crea una configuración usada para abrir un diccionario.

pspell_config_create() tienen una sintaxis muy parecida a la de pspell_new(). De hecho, al usar pspell_config_create() seguido inmediatemante de pspell_new_config() producirá exactamente el mismo resultado. Sin embargo, después de crear una nueva configuración también se pueden usar las funciones pspell_config_*() antes de llamar a pspell_new_config() para tomar ventaja de algunas funcionalidades avanzadas.

Para más información y ejemplos, verifique el sitio web de pspell del manual en línea:» http://aspell.net/.

Parámetros

language

El parámetro language es el código de lenguaje que consiste en el código de lenguaje ISO 639 de dos letras y un código de país ISO 3166 de dos letras opcional después de un guión o guión de subrayado.

spelling

El parámetro spelling es la ortografía solicitada para lenguajes con más de una ortografía, como el inglés. Valores conocidos son 'american', 'british', y 'canadian'.

jargon

El parámetro jargon contiene información extra para distinguir dos listas de palabras diferentes que tienen el mismo lenguaje y parámetros de ortografía.

encoding

El parámetro encoding es la codificación que se espera que tengan esas palabras. Los valores válidos son 'utf-8', 'iso8859-*', 'koi8-r', 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned 32'. Este parámetro no está en gran parte comprobado, por lo que, tenga cuidado al usarlo.

Valores devueltos

Devuelve un identificador de configuración de ortografía, o false en caso de error.

Ejemplos

Ejemplo #1 pspell_config_create()

<?php
$pspell_config
= pspell_config_create("en");
pspell_config_personal($pspell_config, "/var/dictionaries/custom.pws");
pspell_config_repl($pspell_config, "/var/dictionaries/custom.repl");
$pspell_link = pspell_new_personal($pspell_config, "en");
?>

add a note

User Contributed Notes 1 note

up
0
mshort at mail dot com
10 months ago
This might help if you are trying to use multiple custom dictionaries especially if you don't have sudo access to the system aspell dictionary directory ...
I created three custom dictionaries (or are they word lists) using "aspell create master" and found a way to use them ...
1) Create 3 word lists, one word per line, wordlistA.txt, wordlistB.txt, and wordlistC.txt.
2) Create 3 masters ... aspell --lang=en create master ./my_LANG-dictA.rws < wordlistA.txt - repeat for B and C (lang needs to be already installed, I think any lang will work).
3) Create 3 multi files, my_LANGA.multi, contents: add my_LANG-dictA.rws) - repeat for B and C. Where my_LANGA can be any name in the same case as explained in the aspell manual.
4) Use any one of them (A B or C) with pspell ...
<?php
$pspell_config
= pspell_config_create('my_LANGC', '', ''. 'utf-8');
pspell_config_dict_dir($pspell_config, <location of my_LANGC.multi>);
if ((
$pspell = pspell_new_config($pspell_config)) == false) {
echo
'pspell_new_config() for LANGC FAILED!');
} else {
$word = 'PHPisgreat'];
if (
pspell_check($pspell, $word)) {
echo
"$word: Valid spelling";
} else {
$suggestions = pspell_suggest($pspell, $word);
echo
"$word: suggestions: $suggestions"
}
}
?>

The language arg for pspell_config_create() is the basename of the .multi file.
Note that I do not have a file $HOME/.aspell.conf.
Note that my .multi and .rws files are in the same directory, which I think is necessary.
The wordlist files are not needed once the masters are created.
To Top