4 * Default wordbreaker module for full text indexing.
17 #include <sys/types.h>
19 #if TIME_WITH_SYS_TIME
20 # include <sys/time.h>
24 # include <sys/time.h>
36 #include "sysdep_decls.h"
37 #include "citserver.h"
40 #include "serv_extensions.h"
45 #include "ft_wordbreaker.h"
49 void wordbreaker(char *text, int *num_tokens, int **tokens) {
51 int wb_num_tokens = 0;
53 int *wb_tokens = NULL;
64 if (text == NULL) { /* no NULL text please */
70 if (text[0] == 0) { /* no empty text either */
90 /* extract the word */
91 word_len = word_end - word_start + 1;
92 safestrncpy(word, word_start, sizeof word);
96 /* are we ok with the length? */
97 if ( (word_len >= WB_MIN)
98 && (word_len <= WB_MAX) ) {
99 for (i=0; i<word_len; ++i) {
100 word[i] = tolower(word[i]);
103 CalcCRC16Bytes(word_len, word);
106 if (wb_num_tokens > wb_num_alloc) {
108 wb_tokens = realloc(wb_tokens, (sizeof(int) * wb_num_alloc));
110 wb_tokens[wb_num_tokens - 1] = word_crc;
116 *num_tokens = wb_num_tokens;