-// FIXME. The definition of a word is crude here.. should support
-// some form of localization mechanism?
-void relevance_countwords(struct relevance *r, struct record_cluster *cluster,
- const char *words, int multiplier)
-{
-#if !USE_TRIE
- WRBUF norm_str = wrbuf_alloc();
-#endif
- while (*words)
- {
- char c;
- int res;
-#if USE_TRIE
- int skipped = 0;
-#endif
- while (*words && (c = raw_char(tolower(*words))) < 0)
- words++;
- if (!*words)
- return;
-#if USE_TRIE
- res = word_trie_match(r->wt, words, &skipped);
- if (res)
- {
- words += skipped;
- cluster->term_frequency_vec[res] += multiplier;
- }
- else
- {
- while (*words && (c = raw_char(tolower(*words))) >= 0)
- words++;
- }
-#else
- while (*words && (c = raw_char(tolower(*words))) >= 0)
- {
- wrbuf_putc(norm_str, c);
- words++;
- }
- res = word_entry_match(r->entries, wrbuf_cstr(norm_str));
- if (res)
- cluster->term_frequency_vec[res] += multiplier;
- wrbuf_rewind(norm_str);
-#endif
- cluster->term_frequency_vec[0]++;
- }
-#if !USE_TRIE
- wrbuf_destroy(norm_str);
-#endif
-}
-