php-doc-en/functions/pspell.xml
Egon Schmid 1c0c3f3d0a Beautified it a bit.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@29908 c90b9560-bf6c-de11-be94-00142212c4b1
2000-08-08 19:45:33 +00:00

220 lines
6.5 KiB
XML

<reference id="ref.pspell">
<title>Pspell Functions</title>
<titleabbrev>Pspell</titleabbrev>
<partintro>
<simpara>
The <function>pspell</function> functions allow you to check the
spelling of a word and offer suggestions.
</simpara>
<simpara>
You need the aspell and pspell libraries, available from <ulink
url="&url.aspell;">&url.aspell;</ulink> and
<ulink url="&url.pspell;">&url.pspell;</ulink> respectively, and
add the <option role="configure">--with-pspell[=dir]</option> option
when compiling php.
</simpara>
</partintro>
<refentry id="function.pspell-new">
<refnamediv>
<refname>pspell_new</refname>
<refpurpose>Load a new dictionary</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>pspell_new</function></funcdef>
<paramdef>string <parameter>language</parameter></paramdef>
<paramdef>string
<parameter>
<optional>spelling</optional>
</parameter>
</paramdef>
<paramdef>string
<parameter>
<optional>jargon</optional>
</parameter>
</paramdef>
<paramdef>string
<parameter>
<optional>encoding</optional>
</parameter>
</paramdef>
<paramdef>int
<parameter>
<optional>mode</optional>
</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<simpara>
<function>Pspell_new</function> opens up a new dictionary and
returns the dictionary link identifier for use in other pspell
functions.
</simpara>
<para>
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.
</para>
<para>
The spelling parameter is the requested spelling for languages
with more than one spelling such as English. Known values are
'american', 'british', and 'canadian'.
</para>
<para>
The jargon parameter contains extra information to distinguish
two different words lists that have the same language and
spelling parameters.
</para>
<para>
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.
</para>
<para>
The mode parameter is the mode in which spellchecker will work.
There are several modes available:
<itemizedlist>
<listitem>
<simpara>
PSPELL_FAST - Fast mode (least number of suggestions)
</simpara>
</listitem>
<listitem>
<simpara>
PSPELL_NORMAL - Normal mode (more suggestions)
</simpara>
</listitem>
<listitem>
<simpara>
PSPELL_BAD_SPELLERS - Slow mode (a lot of suggestions)
</simpara>
</listitem>
<listitem>
<simpara>
PSPELL_RUN_TOGETHER - Consider run-together words as legal
compounds. That is, "thecat" will be a legal compound,
athough there should be a space between the two
words. Changing this setting only affects the results returned
by <function>pspell_check</function>;
<function>pspell_suggest</function> will still return
suggestions.
</simpara>
</listitem>
</itemizedlist>
Mode is a bitmask constructed from different constants listed
above. However, PSPELL_FAST, PSPELL_NORMAL and
PSPELL_BAD_SPELLERS are mutually exclusive, so you should select
only one of them.
</para>
<para>
For more information and examples, check out inline manual pspell
website:<ulink url="&url.pspell;">&url.pspell;</ulink>.
</para>
<para>
<example>
<title><function>Pspell_new</function></title>
<programlisting role="php">
$pspell_link = pspell_new ("en", "", "", "",
(PSPELL_FAST|PSPELL_RUN_TOGETHER));
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<refentry id="function.pspell-check">
<refnamediv>
<refname>pspell_check</refname>
<refpurpose>Check a word</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>boolean <function>pspell_check</function></funcdef>
<paramdef>int <parameter>dictionary_link</parameter></paramdef>
<paramdef>string <parameter>word</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<simpara>
<function>Pspell_check</function> checks the spelling of a word
and returns true if the spelling is correct, false if not.
</simpara>
<para>
<example>
<title><function>Pspell_check</function></title>
<programlisting role="php">
$pspell_link = pspell_new ("en");
if (pspell_check ($pspell_link, "testt")) {
echo "This is a valid spelling";
} else {
echo "Sorry, wrong spelling";
}
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<refentry id="function.pspell-suggest">
<refnamediv>
<refname>pspell_suggest</refname>
<refpurpose>Suggest spellings of a word</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>array <function>pspell_suggest</function></funcdef>
<paramdef>int <parameter>dictionary_link</parameter></paramdef>
<paramdef>string <parameter>word</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<simpara>
<function>Pspell_suggest</function> returns an array of possible
spellings for the given word.
</simpara>
<para>
<example>
<title><function>Pspell_suggest</function></title>
<programlisting role="php">
$pspell_link = pspell_new ("en");
if (!pspell_check ($pspell_link, "testt")) {
$suggestions = pspell_suggest ($pspell_link, "testt");
for ($i=0; $i &lt; count ($suggestions); $i++) {
echo "Possible spelling: " . $suggestions[$i] . "&lt;br>";
}
}
</programlisting>
</example>
</para>
</refsect1>
</refentry>
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->