(PHP 4 >= 4.0.2, PHP 5, PHP 7, PHP 8)
pspell_config_create — Crea una configuración utilizada para abrir un diccionario
$language,$spelling = "",$jargon = "",$encoding = ""Crea una configuración utilizada para abrir un diccionario.
pspell_config_create() tiene una sintaxis similar a la de pspell_new() . De hecho, utilizar pspell_config_create() seguido inmediatamente por pspell_new_config() producirá exactamente el mismo resultado. Sin embargo, después de crear una nueva configuración, también pueden utilizarse las funciones pspell_config_*() antes de llamar a pspell_new_config() para aprovechar las funcionalidades avanzadas.
Para obtener más información y ejemplos, consúltese el manual en línea en el sitio de pspell : » http://aspell.net/.
language
El argumento de lenguaje language es el código
de idioma en dos letras,
definido en la norma ISO 639, y dos letras opcionales
ISO 3166, después de un guión o un subrayado (_).
spelling
El argumento de ortografía spelling es
necesario para los idiomas que tienen más de una ortografía,
como el inglés. Los valores reconocidos son entonces 'american'
(americano), 'british' (inglés), y 'canadian' (canadiense).
jargon
El argumento de jergas jargon contiene
información adicional para distinguir dos diccionarios
distintos para el mismo idioma y el mismo argumento
de ortografía spelling.
encoding
El argumento de codificación encoding indica
la codificación esperada para la respuesta.
Los valores válidos son : 'utf-8', 'iso8859-*', 'koi8-r',
'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned 32'.
Este argumento no ha sido probado de
manera exhaustiva, por lo que se recomienda precaución.
Devuelve una instancia de PSpell\Config .
| Versión | Descripción |
|---|---|
| 8.1.0 | Ahora devuelve una instancia de PSpell\Config ; anteriormente, se devolvía un resource . |
Ejemplo #1 pspell_config_create()
<?php
$pspell_config = pspell_config_create("fr");
pspell_config_personal($pspell_config, "/var/dictionaries/custom.pws");
pspell_config_repl($pspell_config, "/var/dictionaries/custom.repl");
$pspell = pspell_new_personal($pspell_config, "fr");
?>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.