/** * 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); }
/** * 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; }