Forum und email

SwishResult->stem

(PECL swish:0.1-0.3.0)

SwishResult->stem — Stems the given word

說明

array SwishResult->stem ( string $word )
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.

Return值

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

錯誤/例外

Throws SwishException on error.

範例

Example#1 Basic 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 th 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"
}