function search_expand_cjk in Drupal 6
Same name and namespace in other branches
- 8 core/modules/search/search.module \search_expand_cjk()
- 4 modules/search.module \search_expand_cjk()
- 5 modules/search/search.module \search_expand_cjk()
- 7 modules/search/search.module \search_expand_cjk()
- 9 core/modules/search/search.module \search_expand_cjk()
Basic CJK tokenizer. Simply splits a string into consecutive, overlapping sequences of characters ('minimum_word_size' long).
1 string reference to 'search_expand_cjk'
- search_simplify in modules/
search/ search.module - Simplifies a string according to indexing rules.
File
- modules/
search/ search.module, line 342 - Enables site-wide keyword searching.
Code
function search_expand_cjk($matches) {
$min = variable_get('minimum_word_size', 3);
$str = $matches[0];
$l = drupal_strlen($str);
// Passthrough short words
if ($l <= $min) {
return ' ' . $str . ' ';
}
$tokens = ' ';
// FIFO queue of characters
$chars = array();
// Begin loop
for ($i = 0; $i < $l; ++$i) {
// Grab next character
$current = drupal_substr($str, 0, 1);
$str = substr($str, strlen($current));
$chars[] = $current;
if ($i >= $min - 1) {
$tokens .= implode('', $chars) . ' ';
array_shift($chars);
}
}
return $tokens;
}