📄 function.udm-load-ispell-data.html
字号:
<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><p><b class="note">Note</b>: <i><tt class="parameter">flag</tt></i> is equal to <i>1</i> only in the last call. <br /> </p></blockquote> </li> <li class="listitem"> <p class="para"> UDM_ISPELL_TYPE_SERVER - enables spell server support. <i><tt class="parameter">val1</tt></i> parameter indicates address of the host running spell server. <i><tt class="parameter">val2</tt></i> ` is not used yet, but in future releases it is going to indicate number of port used by spell server. <i><tt class="parameter">flag</tt></i> 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 (/usr/local/mnogosearch/etc/spelld.conf 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"> <b>udm_load_ispell_data()</b> function in UDM_ISPELL_TYPE_SERVER mode does not actually load ispell data, but only defines server address. In fact, server is automatically used by <a href="function.udm-find.html" class="function">udm_find()</a> 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><p><b class="note">Note</b>: This function is available in mnoGoSearch 3.1.12 or later. <br /> </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 UDM_ISPELL_TYPE_SERVER. UDM_ISPELL_TYPE_TEXT is slower and UDM_ISPELL_TYPE_DB is the slowest. The above pattern is <b><tt>TRUE</tt></b> 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"><i><tt class="parameter">val1</tt></i></span> <dd> <p class="para"> </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">val2</tt></i></span> <dd> <p class="para"> </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">flag</tt></i></span> <dd> <p class="para"> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <b><tt>TRUE</tt></b> on success or <b><tt>FALSE</tt></b> on failure. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #2 <b>udm_load_ispell_data()</b> example</b></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 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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -