PHP 8.1.24 Released!

pspell_config_create

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

pspell_config_create辞書をオープンする際に使用する設定を作成する

説明

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

辞書をオープンする際に使用する設定を作成します。

pspell_config_create() は、 pspell_new() の構文に非常によく似ています。実際、 pspell_new_config() の直後に pspell_config_create() を使用した場合、全く同じ 結果となります。しかし、新しい設定を作成した後、 pspell_new_config() をコールする前に関数 pspell_config_*() を使用することで いくつかの進んだ機能が使用できます。

より詳細な情報と例については、pspell Web サイト » http://aspell.net/ のオンラインマニュアルを参照ください。

パラメータ

language

パラメータ language は、2 文字の ISO 639 言語コードと オプションでダッシュまたはアンダースコアの後に 2 文字の ISO 3166 国コードからなる言語コードです。

spelling

パラメータ spelling は、英語のように複数のスペルがある言語に関して スペルの指定を行うものです。指定可能な値は、 'american', 'british', 'canadian'です。

jargon

パラメータ jargon は、同じ language および spelling パラメータを有する 2 つの異なる単語リストを区別するための 追加情報を有しています。

encoding

パラメータ encoding は、単語のエンコーディングとして 予想されるものです。有効な値は、'utf-8', 'iso8859-*', 'koi8-r', 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned 32' です。このパラメータはよくテストされていないため、 使用する際には注意してください。

戻り値

PSpell\Config クラスのインスタンスを返します。

変更履歴

バージョン 説明
8.1.0 PSpell\Config クラスのインスタンスを返すようになりました。 これより前のバージョンでは、リソース を返していました。

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

add a note

User Contributed Notes 1 note

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