pspell_config_create
(PHP 4 >= 4.0.2, PHP 5)
pspell_config_create — Create a config used to open a dictionary
Описание
Create a config used to open a dictionary.
pspell_config_create() has a very similar syntax to pspell_new(). In fact, using pspell_config_create() immediately followed by pspell_new_config() will produce the exact same result. However, after creating a new config, you can also use pspell_config_*() functions before calling pspell_new_config() to take advantage of some advanced functionality.
For more information and examples, check out inline manual pspell website:» http://aspell.net/.
Список параметров
- language
-
The language parameter is the language code which consists of the two letter ISO 639 language code and an optional two letter ISO 3166 country code after a dash or underscore.
- spelling
-
The spelling parameter is the requested spelling for languages with more than one spelling such as English. Known values are 'american', 'british', and 'canadian'.
- jargon
-
The jargon parameter contains extra information to distinguish two different words lists that have the same language and spelling parameters.
- encoding
-
The encoding parameter is the encoding that words are expected to be in. Valid values are 'utf-8', 'iso8859-*', 'koi8-r', 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned 32'. This parameter is largely untested, so be careful when using.
Возвращаемые значения
Retuns a pspell config identifier, or FALSE on error.
Примеры
Пример #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");
?>
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Поддержка языков и кодировок
- Pspell
- pspell_add_to_personal
- pspell_add_to_session
- pspell_check
- pspell_clear_session
- pspell_config_create
- pspell_config_data_dir
- pspell_config_dict_dir
- pspell_config_ignore
- pspell_config_mode
- pspell_config_personal
- pspell_config_repl
- pspell_config_runtogether
- pspell_config_save_repl
- pspell_new_config
- pspell_new_personal
- pspell_new
- pspell_save_wordlist
- pspell_store_replacement
- pspell_suggest
Коментарии
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.