PHP Conference Fukuoka 2025

pspell_config_create

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

pspell_config_createCria uma configuração usada para abrir um dicionário

Descrição

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

Cria uma configuração usada para abrir um dicionário.

pspell_config_create() tem uma sintaxe muito semelhante a pspell_new(). De fato, usar pspell_config_create() imediatamente seguido por pspell_new_config() produzirá exatamente o mesmo resultado. No entanto, após criar uma nova configuração, também podem ser usadas as funções pspell_config_*() antes de chamar pspell_new_config() para aproveitar algumas funcionalidades avançadas.

Para mais informações e exemplos, confira o manual no site do pspell:» http://aspell.net/.

Parâmetros

language

O parâmetro language é o código do idioma, que consiste no código de idioma ISO 639 de duas letras e um código de país ISO 3166 opcional de duas letras após um hífen ou sublinhado.

spelling

O parâmetro spelling é a ortografia solicitada para idiomas com mais de uma grafia, como o inglês. Os valores conhecidos são 'american', 'british' e 'canadian'.

jargon

O parâmetro jargon contém informações extras para distinguir duas listas de palavras diferentes que possuem os mesmos parâmetros de idioma e ortografia.

encoding

O parâmetro encoding é a codificação em que se espera que as palavras estejam. Os valores válidos são 'utf-8', 'iso8859-*', 'koi8-r', 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned 32'. Este parâmetro ainda não foi testado, portanto, tenha cuidado ao usá-lo.

Valor Retornado

Retorna uma instância de PSpell\Config.

Registro de Alterações

Versão Descrição
8.1.0 Retorna uma instância de PSpell\Config agora; anteriormente, um resource era retornado.

Exemplos

Exemplo #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 = pspell_new_personal($pspell_config, "en");
?>

adicionar nota

Notas de Usuários 1 note

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