本文整理汇总了PHP中Lookup::stopwords方法的典型用法代码示例。如果您正苦于以下问题:PHP Lookup::stopwords方法的具体用法?PHP Lookup::stopwords怎么用?PHP Lookup::stopwords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lookup
的用法示例。
在下文中一共展示了Lookup::stopwords方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: StopFilter
/**
* Removes stop words from the text
*
* Stop words are words that are common English words that
* are not particularly useful for searching.
*
* @since 1.1
*
* @param string $text The text to clean up
* @return string The cleaned text
**/
static function StopFilter ($text) {
$stopwords = Lookup::stopwords();
$replacements = implode('|',$stopwords);
return preg_replace("/\b($replacements)\b/",'',$text);
}
示例2: StopFilter
/**
* Removes stop words from the text
*
* Stop words are words that are common English words that
* are not particularly useful for searching.
*
* @author Jonathan Davis
* @since 1.1
*
* @param string $text The text to clean up
* @return string The cleaned text
**/
public static function StopFilter($text)
{
$stopwords = Lookup::stopwords();
$replacements = implode('|', $stopwords);
// Protect quoted strings
$result = '';
$unquoted = preg_split('/("[^"]*"|\'[^\']*\')/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
while ($unquoted) {
$result .= preg_replace("/\\b({$replacements})\\b/", '', array_shift($unquoted)) . array_shift($unquoted);
}
return $result;
}