27 #include <yaz/wrbuf.h>
38 NMEM nmem = nmem_create();
48 nmem_destroy(l->
nmem);
52 zint seqno,
int ws,
int ord,
const char *term)
58 zint seqno,
int ws,
int ord,
const char *term,
66 zint seqno,
int ws,
int ord,
67 const char *term,
size_t term_len,
87 w->
term = nmem_malloc(l->
nmem, term_len+1);
89 w->
term[term_len] =
'\0';
109 WRBUF wr_term = wrbuf_alloc();
110 wrbuf_puts_escaped(wr_term, w->
term);
117 wrbuf_destroy(wr_term);
127 if (window_size == 0)
128 window_size = 1000000;
133 zint first_seq_no_best_window = 0;
134 zint last_seq_no_best_window = 0;
135 int number_best_window = 0;
141 (min_ord == 0 || hit_w->
ord < min_ord))
143 min_ord = hit_w->
ord;
155 zint seq_no_last = 0;
156 while (look_w && look_w->
seqno < hit_w->
seqno + window_size)
160 seq_no_last = look_w->
seqno;
163 look_w = look_w->
next;
165 if (number_this > number_best_window)
167 number_best_window = number_this;
168 first_seq_no_best_window = hit_w->
seqno;
169 last_seq_no_best_window = seq_no_last;
173 yaz_log(YLOG_DEBUG,
"ord=%d",
ord);
174 yaz_log(YLOG_DEBUG,
"first_seq_no_best_window=" ZINT_FORMAT,
175 first_seq_no_best_window);
176 yaz_log(YLOG_DEBUG,
"last_seq_no_best_window=" ZINT_FORMAT,
177 last_seq_no_best_window);
178 yaz_log(YLOG_DEBUG,
"number_best_window=%d", number_best_window);
180 window_start = (first_seq_no_best_window + last_seq_no_best_window -
184 && doc_w->
seqno >= window_start
185 && doc_w->
seqno < window_start + window_size)
238 int before,
int after)
251 (min_ord == 0 || hit_w->
ord < min_ord))
253 min_ord = hit_w->
ord;
zebra_snippet_word * zebra_snippets_list(zebra_snippets *l)
void zebra_snippets_append_match(zebra_snippets *l, zint seqno, int ws, int ord, const char *term, size_t term_len, int match)
void zebra_snippets_appendn(zebra_snippets *l, zint seqno, int ws, int ord, const char *term, size_t term_len)
static void zebra_snippets_clear(zebra_snippets *sn)
void zebra_snippets_log(const zebra_snippets *l, int log_level, int all)
void zebra_snippets_destroy(zebra_snippets *l)
const zebra_snippet_word * zebra_snippets_constlist(const zebra_snippets *l)
void zebra_snippets_append(zebra_snippets *l, zint seqno, int ws, int ord, const char *term)
const struct zebra_snippet_word * zebra_snippets_lookup(const zebra_snippets *doc, const zebra_snippets *hit)
void zebra_snippets_ring(zebra_snippets *doc, const zebra_snippets *hit, int before, int after)
zebra_snippets * zebra_snippets_window(const zebra_snippets *doc, const zebra_snippets *hit, int window_size)
zebra_snippets * zebra_snippets_create(void)
struct zebra_snippet_word * prev
struct zebra_snippet_word * next
zebra_snippet_word * tail
zebra_snippet_word * front