<!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><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.udm-hash32.html">udm_hash32</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.udm-open-stored.html">udm_open_stored</a></div> <div class="up"><a href="ref.mnogosearch.html">mnoGoSearch Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><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.0.5, 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">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <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> )</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="function.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">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">agent</code></em></span> <dd> <p class="para"> A link to Agent, received after call to <span class="function"><a href="function.udm-alloc-agent.html" class="function">udm_alloc_agent()</a></span>. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">var</code></em></span> <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 <em><code class="parameter">val1</code></em> and <em><code class="parameter">val2</code></em> are ignored and should be left blank. <em><code class="parameter">flag</code></em> should be equal to <em>1</em>. </span> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> <em><code class="parameter">flag</code></em> 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="function.udm-error.html" class="function">udm_error()</a></span> and <span class="function"><a href="function.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 <em><code class="parameter">val1</code></em> defines double letter language code for which affixes are loaded, and <em><code class="parameter">val2</code></em> - 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="function.udm-error.html" class="function">udm_error()</a></span> and <span class="function"><a href="function.udm-errno.html" class="function">udm_errno()</a></span>, since those functions can only return messages associated with SQL. Please, see <em><code class="parameter">flag</code></em> parameter description in <strong><code>UDM_ISPELL_TYPE_DB</code></strong>. </p> <p class="para"> <div class="example" id="example-4704"> <p><strong>Example #1 <span class="function"><strong>udm_load_ispell_data()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><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> </code></div> </div> </div> </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> <em><code class="parameter">flag</code></em> 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 <em><code class="parameter">val1</code></em> defines double letter language code for which affixes are loaded, and <em><code class="parameter">val2</code></em> - 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="function.udm-error.html" class="function">udm_error()</a></span> and <span class="function"><a href="function.udm-errno.html" class="function">udm_errno()</a></span>, since those functions can only return messages associated with SQL. Please, see <em><code class="parameter">flag</code></em> parameter description in <strong><code>UDM_ISPELL_TYPE_DB</code></strong>. </p> <div class="informalexample"> <div class="example-contents"> <div class="phpcode"><code><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> </code></div> </div> </div> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> <em><code class="parameter">flag</code></em> 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. <em><code class="parameter">val1</code></em> parameter indicates address of the host running spell server. <em><code class="parameter">val2</code></em> ` is not used yet, but in future releases it is going to indicate number of port used by spell server. <em><code class="parameter">flag</code></em> 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="function.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"><code><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> </code></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> <dt> <span class="term"><em><code class="parameter">val1</code></em></span> <dd> <p class="para"> </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">val2</code></em></span> <dd> <p class="para"> </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">flag</code></em></span> <dd> <p class="para"> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.udm-load-ispell-data-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure. </p> </div> <div class="refsect1 examples" id="refsect1-function.udm-load-ispell-data-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4705"> <p><strong>Example #2 <span class="function"><strong>udm_load_ispell_data()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><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> </code></div> </div> </div> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.udm-hash32.html">udm_hash32</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.udm-open-stored.html">udm_open_stored</a></div> <div class="up"><a href="ref.mnogosearch.html">mnoGoSearch Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>