mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 22:06:57 +08:00
268 lines
18 KiB
HTML
268 lines
18 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
<html>
|
||
<head>
|
||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||
<title>Load ispell data</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><div id="function.udm-load-ispell-data" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">udm_load_ispell_data</h1>
|
||
<p class="verinfo">(PHP 4 >= 4.0.5, PHP 5 < 5.1.0, PECL mnogosearch >= 1.0.0)</p><p class="refpurpose"><span class="refname">udm_load_ispell_data</span> — <span class="dc-title">Load ispell data</span></p>
|
||
|
||
</div>
|
||
|
||
<div class="refsect1 description" id="refsect1-function.udm-load-ispell-data-description">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>udm_load_ispell_data</strong></span>
|
||
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$agent</code></span>
|
||
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$var</code></span>
|
||
, <span class="methodparam"><span class="type">string</span> <code class="parameter">$val1</code></span>
|
||
, <span class="methodparam"><span class="type">string</span> <code class="parameter">$val2</code></span>
|
||
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flag</code></span>
|
||
) : <span class="type">bool</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
<span class="function"><strong>udm_load_ispell_data()</strong></span> loads ispell data.
|
||
</p>
|
||
<p class="para">
|
||
After using this function to free memory allocated for ispell data, please
|
||
use <span class="function"><a href="udm_free_ispell_data.html" class="function">udm_free_ispell_data()</a></span>, even if you use
|
||
<strong><code>UDM_ISPELL_TYPE_SERVER</code></strong> mode.
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 parameters" id="refsect1-function.udm-load-ispell-data-parameters">
|
||
<h3 class="title">参数</h3>
|
||
<p class="para">
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">agent</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
A link to Agent, received after call to
|
||
<span class="function"><a href="udm_alloc_agent.html" class="function">udm_alloc_agent()</a></span>.
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">var</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
Indicates the source for ispell data. May have the following values:
|
||
<ul class="itemizedlist">
|
||
<li class="listitem">
|
||
<span class="simpara">
|
||
<strong><code>UDM_ISPELL_TYPE_DB</code></strong> - indicates that ispell data should be loaded from SQL.
|
||
In this case, parameters <code class="parameter">val1</code> and <code class="parameter">val2</code>
|
||
are ignored and should be left blank. <code class="parameter">flag</code>
|
||
should be equal to <em>1</em>.
|
||
</span>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<p class="para">
|
||
<code class="parameter">flag</code> indicates that after loading ispell data
|
||
from defined source it should be sorted (it is necessary for correct
|
||
functioning of ispell). In case of loading ispell data from files
|
||
there may be several calls to <span class="function"><strong>udm_load_ispell_data()</strong></span>,
|
||
and there is no sense to sort data after every call, but only after
|
||
the last one. Since in db mode all the data is loaded by one call,
|
||
this parameter should have the value <em>1</em>. In this mode
|
||
in case of error, e.g. if ispell tables are absent, the function will
|
||
return <strong><code>FALSE</code></strong> and code and error message will be accessible through
|
||
<span class="function"><a href="udm_error.html" class="function">udm_error()</a></span> and <span class="function"><a href="udm_errno.html" class="function">udm_errno()</a></span>.
|
||
</p>
|
||
</p></blockquote>
|
||
</li>
|
||
<li class="listitem">
|
||
<p class="para">
|
||
<strong><code>UDM_ISPELL_TYPE_AFFIX</code></strong> - indicates that ispell data should be loaded from
|
||
file and initiates loading affixes file. In this case <code class="parameter">val1</code>
|
||
defines double letter language code for which affixes are loaded,
|
||
and <code class="parameter">val2</code> - file path. Please note, that if
|
||
a relative path entered, the module looks for the file not in <strong><code>UDM_CONF_DIR</code></strong>,
|
||
but in relation to current path, i.e. to the path where the script is executed.
|
||
In case of error in this mode, e.g. if file is absent, the function will return
|
||
<strong><code>FALSE</code></strong>, and an error message will be displayed. Error message text cannot be
|
||
accessed through <span class="function"><a href="udm_error.html" class="function">udm_error()</a></span> and <span class="function"><a href="udm_errno.html" class="function">udm_errno()</a></span>,
|
||
since those functions can only return messages associated with SQL. Please,
|
||
see <code class="parameter">flag</code> parameter description in <strong><code>UDM_ISPELL_TYPE_DB</code></strong>.
|
||
</p>
|
||
<p class="para">
|
||
<div class="example" id="zookeeper.getacl.example.basic">
|
||
<p><strong>Example #1 <span class="function"><strong>udm_load_ispell_data()</strong></span> example</strong></p>
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">if ((! </span><span style="color: #0000BB">udm_load_ispell_data</span><span style="color: #007700">(</span><span style="color: #0000BB">$udm</span><span style="color: #007700">, </span><span style="color: #0000BB">UDM_ISPELL_TYPE_AFFIX</span><span style="color: #007700">, </span><span style="color: #DD0000">'en'</span><span style="color: #007700">, </span><span style="color: #DD0000">'/opt/ispell/en.aff'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">)) ||<br /> (! </span><span style="color: #0000BB">udm_load_ispell_data</span><span style="color: #007700">(</span><span style="color: #0000BB">$udm</span><span style="color: #007700">, </span><span style="color: #0000BB">UDM_ISPELL_TYPE_AFFIX</span><span style="color: #007700">, </span><span style="color: #DD0000">'ru'</span><span style="color: #007700">, </span><span style="color: #DD0000">'/opt/ispell/ru.aff'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">)) ||<br /> (! </span><span style="color: #0000BB">udm_load_ispell_data</span><span style="color: #007700">(</span><span style="color: #0000BB">$udm</span><span style="color: #007700">, </span><span style="color: #0000BB">UDM_ISPELL_TYPE_SPELL</span><span style="color: #007700">, </span><span style="color: #DD0000">'en'</span><span style="color: #007700">, </span><span style="color: #DD0000">'/opt/ispell/en.dict'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">)) ||<br /> (! </span><span style="color: #0000BB">udm_load_ispell_data</span><span style="color: #007700">(</span><span style="color: #0000BB">$udm</span><span style="color: #007700">, </span><span style="color: #0000BB">UDM_ISPELL_TYPE_SPELL</span><span style="color: #007700">, </span><span style="color: #DD0000">'ru'</span><span style="color: #007700">, </span><span style="color: #DD0000">'/opt/ispell/ru.dict'</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">))) {<br /> exit;<br />}<br /></span><span style="color: #0000BB">?></span>
|
||
</span>
|
||
</pre></div>
|
||
</div>
|
||
|
||
</div>
|
||
</p>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<p class="para">
|
||
<code class="parameter">flag</code> is equal to <em>1</em> only in the last call.
|
||
</p>
|
||
</p></blockquote>
|
||
</li>
|
||
<li class="listitem">
|
||
<p class="para">
|
||
<strong><code>UDM_ISPELL_TYPE_SPELL</code></strong> - indicates that ispell data should be loaded from
|
||
file and initiates loading of ispell dictionary file. In this case
|
||
<code class="parameter">val1</code> defines double letter language code for which
|
||
affixes are loaded,
|
||
and <code class="parameter">val2</code> - file path. Please note, that if a relative
|
||
path entered, the module looks for the file not in <strong><code>UDM_CONF_DIR</code></strong>, but in
|
||
relation to current path, i.e. to the path where the script is executed.
|
||
In case of error in this mode, e.g. if file is absent, the function will
|
||
return <strong><code>FALSE</code></strong>, and an error message will be displayed. Error message text
|
||
cannot be accessed through <span class="function"><a href="udm_error.html" class="function">udm_error()</a></span> and
|
||
<span class="function"><a href="udm_errno.html" class="function">udm_errno()</a></span>, since those functions can only return messages
|
||
associated with SQL. Please, see <code class="parameter">flag</code> parameter
|
||
description in <strong><code>UDM_ISPELL_TYPE_DB</code></strong>.
|
||
</p>
|
||
<div class="informalexample">
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">if ((! </span><span style="color: #0000BB">udm_load_ispell_data</span><span style="color: #007700">(</span><span style="color: #0000BB">$udm</span><span style="color: #007700">, </span><span style="color: #0000BB">UDM_ISPELL_TYPE_AFFIX</span><span style="color: #007700">, </span><span style="color: #DD0000">'en'</span><span style="color: #007700">, </span><span style="color: #DD0000">'/opt/ispell/en.aff'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">)) ||<br /> (! </span><span style="color: #0000BB">udm_load_ispell_data</span><span style="color: #007700">(</span><span style="color: #0000BB">$udm</span><span style="color: #007700">, </span><span style="color: #0000BB">UDM_ISPELL_TYPE_AFFIX</span><span style="color: #007700">, </span><span style="color: #DD0000">'ru'</span><span style="color: #007700">, </span><span style="color: #DD0000">'/opt/ispell/ru.aff'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">)) ||<br /> (! </span><span style="color: #0000BB">udm_load_ispell_data</span><span style="color: #007700">(</span><span style="color: #0000BB">$udm</span><span style="color: #007700">, </span><span style="color: #0000BB">UDM_ISPELL_TYPE_SPELL</span><span style="color: #007700">, </span><span style="color: #DD0000">'en'</span><span style="color: #007700">, </span><span style="color: #DD0000">'/opt/ispell/en.dict'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">)) ||<br /> (! </span><span style="color: #0000BB">udm_load_ispell_data</span><span style="color: #007700">(</span><span style="color: #0000BB">$udm</span><span style="color: #007700">, </span><span style="color: #0000BB">UDM_ISPELL_TYPE_SPELL</span><span style="color: #007700">, </span><span style="color: #DD0000">'ru'</span><span style="color: #007700">, </span><span style="color: #DD0000">'/opt/ispell/ru.dict'</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">))) {<br /> exit;<br /> }<br /></span><span style="color: #0000BB">?></span>
|
||
</span>
|
||
</pre></div>
|
||
</div>
|
||
|
||
</div>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<p class="para">
|
||
<code class="parameter">flag</code> is equal to <em>1</em> only in the last call.
|
||
</p>
|
||
</p></blockquote>
|
||
</li>
|
||
<li class="listitem">
|
||
<p class="para">
|
||
<strong><code>UDM_ISPELL_TYPE_SERVER</code></strong> - enables spell server support.
|
||
<code class="parameter">val1</code> parameter indicates
|
||
address of the host running spell server. <code class="parameter">val2</code> `
|
||
is not used yet, but in future releases it is going to indicate number
|
||
of port used by spell server. <code class="parameter">flag</code> parameter in
|
||
this case is not needed since ispell data is stored
|
||
on spellserver already sorted.
|
||
</p>
|
||
<p class="para">
|
||
Spelld server reads spell-data from a separate configuration file
|
||
(<var class="filename">/usr/local/mnogosearch/etc/spelld.conf</var> by default), sorts it and stores in
|
||
memory. With clients server communicates in two ways: to indexer all the
|
||
data is transferred (so that indexer starts faster), from search.cgi server
|
||
receives word to normalize and then passes over to client (search.cgi) list
|
||
of normalized word forms. This allows fastest, compared to db and text modes
|
||
processing of search queries (by omitting loading and sorting all the spell data).
|
||
</p>
|
||
<p class="para">
|
||
<span class="function"><strong>udm_load_ispell_data()</strong></span> function in <strong><code>UDM_ISPELL_TYPE_SERVER</code></strong>
|
||
mode does not actually load ispell data, but only defines server address.
|
||
In fact, server is automatically used by <span class="function"><a href="udm_find.html" class="function">udm_find()</a></span>
|
||
function when performing search. In case of errors, e.g. if spellserver
|
||
is not running or invalid host indicated, there are no messages returned
|
||
and ispell conversion does not work.
|
||
</p>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<p class="para">
|
||
This function is available in mnoGoSearch 3.1.12 or later.
|
||
</p>
|
||
</p></blockquote>
|
||
<span class="simpara">Example:</span>
|
||
<div class="informalexample">
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">if (!</span><span style="color: #0000BB">udm_load_ispell_data</span><span style="color: #007700">(</span><span style="color: #0000BB">$udm</span><span style="color: #007700">, </span><span style="color: #0000BB">UDM_ISPELL_TYPE_SERVER</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">)) {<br /> echo </span><span style="color: #DD0000">"Error loading ispell data from server<br />\n"</span><span style="color: #007700">;<br /> exit;<br />}<br /></span><span style="color: #0000BB">?></span>
|
||
</span>
|
||
</pre></div>
|
||
</div>
|
||
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</p>
|
||
<p class="para">
|
||
The fastest mode is <strong><code>UDM_ISPELL_TYPE_SERVER</code></strong>.
|
||
<strong><code>UDM_ISPELL_TYPE_TEXT</code></strong> is slower
|
||
and <strong><code>UDM_ISPELL_TYPE_DB</code></strong> is the slowest. The above pattern is <strong><code>TRUE</code></strong> for
|
||
mnoGoSearch 3.1.10 - 3.1.11. It is planned to speed up DB mode in future
|
||
versions and it is going to be faster than TEXT mode.
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">val1</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">val2</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">flag</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 returnvalues" id="refsect1-function.udm-load-ispell-data-returnvalues">
|
||
<h3 class="title">返回值</h3>
|
||
<p class="para">
|
||
成功时返回 <strong><code>TRUE</code></strong>, 或者在失败时返回 <strong><code>FALSE</code></strong>。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 examples" id="refsect1-function.udm-load-ispell-data-examples">
|
||
<h3 class="title">范例</h3>
|
||
<p class="para">
|
||
<div class="example" id="zookeeper.getchildren.example.basic">
|
||
<p><strong>Example #2 <span class="function"><strong>udm_load_ispell_data()</strong></span> example</strong></p>
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">if (! </span><span style="color: #0000BB">udm_load_ispell_data</span><span style="color: #007700">(</span><span style="color: #0000BB">$udm</span><span style="color: #007700">, </span><span style="color: #0000BB">UDM_ISPELL_TYPE_DB</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">)) {<br /> </span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"Error #%d: '%s'\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">udm_errno</span><span style="color: #007700">(</span><span style="color: #0000BB">$udm</span><span style="color: #007700">), </span><span style="color: #0000BB">udm_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$udm</span><span style="color: #007700">));<br /> exit;<br />}<br /></span><span style="color: #0000BB">?></span>
|
||
</span>
|
||
</pre></div>
|
||
</div>
|
||
|
||
</div>
|
||
</p>
|
||
</div>
|
||
|
||
|
||
</div></div></div></body></html> |