SwishResult::stem

(PECL swish >= 0.1.0)

SwishResult::stemStems the given word

说明

SwishResult::stem ( string $word ) : array
Warning

此函数是实验性的。此函数的表象,包括名称及其相关文档都可能在未来的 PHP 发布版本中未通知就被修改。使用本函数风险自担 。

Stems the word based on the fuzzy mode used during indexing. Each result object is linked with its index, so the results are based on this index.

参数

word

The word to stem.

返回值

Returns array containing the stemmed word variants (usually just one).

错误/异常

Throws SwishException on error.

范例

Example #1 Basic SwishResult::stem() example

<?php

try {

    
$swish = new Swish("ext/swish/tests/index.swish-e");
    
$results $swish->query("testing OR others");

    if (
$result $results->nextResult()) {
        
var_dump($result->stem("testing")); //the results fully depend on the stemmer used in the index
        
var_dump($result->stem("others"));
    }

} catch (
SwishException $e) {
    echo 
"Error: "$e->getMessage(), "\n";
}

?>

以上例程的输出类似于:

array(1) {
  [0]=>
  string(4) "test"
}
array(1) {
  [0]=>
  string(5) "other"
}

相关文章
php cubrid mysql 兼容性函数 return the type of the column corresponding to the given field offsetphp cubrid 函数 set a read lock on the given oidphp cubrid 函数 set a write lock on the given oidphp enchant 函数 get the directory path for a given backendphp frontbase 函数 get the status for a given databasephp gnupg 函数 signs a given textphp imap 函数 returns a properly formatted email address given the mailbox host and personal infophp intl 函数 check whether the given error code indicates failurephp maxdb 函数 returns whether thread safety is given or notphp postgresql 函数 sends a request to execute a prepared statement with given parameters without waiting for the result s php pspell 函数 load a new dictionary with settings based on a given configphp runkit 函数 dynamically adds a new method to a given classphp sqlite 函数 execute a query against a given database and returns an arrayphp sqlite 函数 executes a query against a given database and returns a result handlephp statistic 函数 calculates any one parameter of the logistic distribution given values for the othersphp statistic 函数 calculates any one parameter of the negative binomial distribution given values for the othersphp sdo das relational 函数 executes a given sql query against a relational database and returns the results as a normalised data graphphp sdo das xml 函数 creates sdo dataobject for a given namespace uri and type namephp swish 函数 stems the given wordphp swish 函数 set current seek pointer to the given position
关注编程学问公众号