-/* $Id: snippet.c,v 1.13 2007-08-21 11:06:47 adam Exp $
+/* $Id: snippet.c,v 1.15 2008-01-24 16:13:29 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
#include <string.h>
#include <yaz/nmem.h>
#include <yaz/log.h>
+#include <yaz/wrbuf.h>
#include <idzebra/snippet.h>
struct zebra_snippets {
zebra_snippet_word *w;
for (w = l->front; w; w = w->next)
{
+ WRBUF wr_term = wrbuf_alloc();
+ wrbuf_puts_escaped(wr_term, w->term);
+
if (all || w->mark)
yaz_log(log_level, "term='%s'%s mark=%d seqno=" ZINT_FORMAT " ord=%d",
- w->term, (w->match && !w->ws ? "*" : ""), w->mark,
+ wrbuf_cstr(wr_term),
+ (w->match && !w->ws ? "*" : ""), w->mark,
w->seqno, w->ord);
+ wrbuf_destroy(wr_term);
}
}
}
}
+const struct zebra_snippet_word *zebra_snippets_lookup(
+ const zebra_snippets *doc, const zebra_snippets *hit)
+{
+ const zebra_snippet_word *hit_w;
+ for (hit_w = zebra_snippets_constlist(hit); hit_w; hit_w = hit_w->next)
+ {
+ const zebra_snippet_word *doc_w;
+ for (doc_w = zebra_snippets_constlist(doc); doc_w; doc_w = doc_w->next)
+ {
+ if (doc_w->ord == hit_w->ord && doc_w->seqno == hit_w->seqno
+ && !doc_w->ws)
+ {
+ return doc_w;
+ }
+ }
+ }
+ return 0;
+}
+
void zebra_snippets_ring(zebra_snippets *doc, const zebra_snippets *hit,
int before, int after)
{