function fuzzysearch_stopwords in Fuzzy Search 6
Remove stop words from search query and text to be indexed.
Parameters
$text: The text to be stripped of stop words.
2 calls to fuzzysearch_stopwords()
- fuzzysearch_index in ./
fuzzysearch.module - Index the node data in the fuzzy index table.
- fuzzysearch_process in ./
fuzzysearch.module - Process the search query
File
- ./
fuzzysearch.module, line 1050 - Module file for fuzzysearch module.
Code
function fuzzysearch_stopwords($text) {
static $stop_words;
if (!is_array($stop_words)) {
$stop_words = array();
$files = file_scan_directory('sites/all/libraries/fuzzysearch/stopwords', 'fuzzysearch_stopwords_.+\\.txt', array(), 0, TRUE, 'name');
foreach ($files as $file) {
$stop_words = array_merge($stop_words, explode(' ', file_get_contents($file->filename)));
}
}
$text = explode(' ', $text);
$text = array_diff($text, $stop_words);
return implode(' ', $text);
}