function search_expand_cjk
Same name and namespace in other branches
- 7.x drupal-7.x/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 drupal-6.x/
modules/ search/ search.module - Simplifies a string according to indexing rules.
Archivo
- drupal-6.x/
modules/ search/ search.module, line 342 - Enables site-wide keyword searching.
Código
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;
}