27 #include <yaz/yaz-util.h>
65 const char *norm_term,
const char *
id,
size_t id_len,
72 if (strlen(norm_term) > 255)
74 strcpy(buf, norm_term);
78 if (!strcmp(buf, (*p)->term.norm_term))
80 (*p)->term.frequency += freq;
88 new->term.norm_term = nmem_strdup(tl->
nmem, buf);
89 new->term.display_term = *display_term ?
90 nmem_strdup(tl->
nmem, display_term) :
new->term.norm_term;
91 new->term.id =
id ? nmem_strdupn(tl->
nmem,
id, id_len) : 0;
92 new->term.frequency = freq;
99 static int compare(
const void *s1,
const void *s2)
103 int d = (*p2)->
frequency - (*p1)->frequency;
106 return strcmp((*p1)->display_term, (*p2)->display_term);
114 nmem_malloc(nmem, tl->
no_entries *
sizeof(*highscore));
118 for (bucket = 0; bucket < tl->
hash_size; bucket++)
122 highscore[no++] = &p->
term;
unsigned int jenkins_hash(const unsigned char *key)
struct termlist_score term
struct termlist_bucket * next
struct termlist_bucket ** hashtable
static int compare(const void *s1, const void *s2)
struct termlist_score ** termlist_highscore(struct termlist *tl, int *len, NMEM nmem)
void termlist_insert(struct termlist *tl, const char *display_term, const char *norm_term, const char *id, size_t id_len, int freq)
struct termlist * termlist_create(NMEM nmem)