Just as a small tip, I noticed that when you call pspell_new multiple times, php does not free memory usage when the resource is destroyed, but only when your entire script has completely finished. So if you create a pspell_link resource and you intend to use it again somewhere else, instead of calling pspell_new again, keep track of your original pspell_link resource instantiation, and use it again, your script will run much more efficiently.
I was switching between 16 dictionaries by just calling a new pspell_new everytime, my memory usage on the server grew until i hit a failure/php core dump. :-/ So i stored each pspell resource in an array keyed by language, and checked if the resource existed first, before creating one if needed.
I hope that helps someone.
pspell_new
(PHP 4 >= 4.0.2, PHP 5)
pspell_new — 新規辞書をロードする
説明
pspell_new() は、新規の辞書をロードして 辞書リンク ID を返します。このリンク ID は、他の pspell 関数で使用されます。
詳細な情報および例については、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' です。このパラメータはよくテストされていないため、 使用する際には注意してください。
- mode
-
パラメータ mode は、スペルチェッカの動作モードです。 使用可能なモードを以下に示します。
- PSPELL_FAST - 高速モード (修正候補の数は最小)
- PSPELL_NORMAL - 通常モード (修正候補はより多い)
- PSPELL_BAD_SPELLERS - 低速モード (修正候補は多い)
- PSPELL_RUN_TOGETHER - つながった単語を複合語 (legal compound)として考慮します。この場合、"thecat" には二つの 単語の間に空白はありませんが複合語となります。この設定の変更は pspell_check() から返される結果にのみ影響します。 設定変更後も pspell_suggest() は修正候補を返します。
返り値
Returns the dictionary link identifier on success, or FALSE on failure.
例
例1 pspell_new()
<?php
$pspell_link = pspell_new("en", "", "", "",
(PSPELL_FAST|PSPELL_RUN_TOGETHER));
?>
pspell_new
29-Sep-2008 11:52
21-Aug-2008 05:00
I think the language and spelling parameters differs on different PHP versions and/or aspell/UNIX distributions.
My PHP 5.2.6 Debian ignores the spelling parameter.
Instead:
For Americans use en_US as language.
For British use en_GB (not en_UK)
For Canadian use en_CA
