CakeFest 2024: The Official CakePHP Conference

pspell_config_create

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

pspell_config_createCrée une configuration utilisée pour ouvrir un dictionnaire

Description

pspell_config_create(
    string $language,
    string $spelling = "",
    string $jargon = "",
    string $encoding = ""
): PSpell\Config

Crée une configuration utilisée pour ouvrir un dictionnaire.

pspell_config_create() a une syntaxe similaire à celle de pspell_new(). En fait, utiliser pspell_config_create() suivi immédiatement par pspell_new_config() produira exactement le même résultat. Cependant, après avoir créé une nouvelle configuration, vous pouvez aussi utiliser les fonctions pspell_config_*() avant d'appeler pspell_new_config() pour tirer profit des fonctionnalités avancées.

Pour davantage d'information et d'exemples, jetez un oeil au manuel en ligne sur le site de pspell : » http://aspell.net/.

Liste de paramètres

language

Le paramètre de langage language est le code de langue en deux lettres, défini dans la norme ISO 639, et deux lettres optionnelles ISO 3166, après un tiret ou un souligné (_).

spelling

Le paramètre d'orthographe spelling est nécessaire pour les langues qui ont plus d'une orthographe, comme l'anglais. Les valeurs reconnues sont alors 'american' (américain) , 'british' (anglais), et 'canadian' (canadien).

jargon

Le paramètre de jargon jargon contient des informations supplémentaires pour distinguer deux dictionnaires distincts pour la même langue et le même paramètre d'orthographe spelling.

encoding

Le paramètre d'encodage encoding indique l'encodage attendu pour la réponse. Les valeurs valides sont : 'utf-8', 'iso8859-*', 'koi8-r', 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned 32'. Ce paramètre n'a pas été testé de manière exhaustive, alors soyez prudent.

Valeurs de retour

Retourne une instance de PSpell\Config.

Historique

Version Description
8.1.0 Retourne désormais une instance de PSpell\Config ; auparavant, une ressource était retournée.

Exemples

Exemple #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");
?>

add a note

User Contributed Notes 1 note

up
0
mshort at mail dot com
6 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