-/* $Id: snippet.h,v 1.3 2005-08-18 19:20:37 adam Exp $
+/* $Id: snippet.h,v 1.4 2005-08-26 10:13:30 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
02111-1307, USA.
*/
-#ifndef SNIPPET_H
-#define SNIPPET_H
+#ifndef IDZEBRA_SNIPPET_H
+#define IDZEBRA_SNIPPET_H
#include <idzebra/util.h>
struct zebra_snippet_word {
zint seqno;
- int reg_type;
int ord;
char *term;
int match;
YAZ_EXPORT
void zebra_snippets_append(zebra_snippets *l,
- zint seqno, int reg_type,
- int ord, const char *term);
+ zint seqno, int ord, const char *term);
YAZ_EXPORT
void zebra_snippets_append_match(zebra_snippets *l,
- zint seqno, int reg_type,
- int ord, const char *term,
+ zint seqno, int ord, const char *term,
int match);
YAZ_EXPORT
-/* $Id: extract.c,v 1.192 2005-08-22 09:04:17 adam Exp $
+/* $Id: extract.c,v 1.193 2005-08-26 10:13:30 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
ZEBRA_RES zebra_snippets_rec_keys(ZebraHandle zh, struct recKeys *reckeys,
zebra_snippets *snippets)
{
- void *decode_handle = iscz1_start();
+ void *decode_handle = iscz1_start();
int off = 0;
int seqno = 0;
NMEM nmem = nmem_create();
- yaz_log(YLOG_LOG, "zebra_rec_keys_snippets buf=%p sz=%d", reckeys->buf,
- reckeys->buf_used);
assert(reckeys->buf);
while (off < reckeys->buf_used)
{
char *dst = (char*) &key;
char dst_buf[IT_MAX_WORD];
char *dst_term = dst_buf;
+ int index_type, ord;
iscz1_decode(decode_handle, &dst, &src);
assert(key.len <= 4 && key.len > 2);
seqno = (int) key.mem[key.len-1];
+ ord = key.mem[0];
- zebra_term_untrans_iconv(zh, nmem, src[0], &dst_term, src+1);
- zebra_snippets_append(snippets, seqno, src[0], key.mem[0], dst_term);
+ zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type,
+ 0/* db */, 0/* set */, 0/* use */);
+ zebra_term_untrans_iconv(zh, nmem, index_type,
+ &dst_term, src);
+ zebra_snippets_append(snippets, seqno, ord, dst_term);
while (*src++)
;
off = src - reckeys->buf;
-/* $Id: retrieve.c,v 1.34 2005-08-19 14:05:29 marc Exp $
+/* $Id: retrieve.c,v 1.35 2005-08-26 10:13:31 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
retrieveCtrl.hit_snippet = hit_snippet;
retrieveCtrl.doc_snippet = zebra_snippets_create();
- if (0)
+ if (1)
{
/* snippets code */
struct recKeys reckeys;
-/* $Id: zinfo.c,v 1.49 2005-08-18 12:50:18 adam Exp $
+/* $Id: zinfo.c,v 1.50 2005-08-26 10:13:31 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
}
int zebraExplain_lookup_ord (ZebraExplainInfo zei, int ord,
- const char **db, int *set, int *use)
+ int *index_type,
+ const char **db,
+ int *set, int *use)
{
struct zebDatabaseInfoB *zdb;
for (zdb = zei->databaseInfo; zdb; zdb = zdb->next)
if (zsui->info.which == ZEB_SU_SET_USE &&
zsui->info.ordinal == ord)
{
- *db = zdb->databaseName;
- *set = zsui->info.u.su.set;
- *use = zsui->info.u.su.use;
+ if (db)
+ *db = zdb->databaseName;
+ if (set)
+ *set = zsui->info.u.su.set;
+ if (use)
+ *use = zsui->info.u.su.use;
+ if (index_type)
+ *index_type = zsui->info.index_type;
return 0;
}
}
-/* $Id: zinfo.h,v 1.26 2005-08-18 12:50:18 adam Exp $
+/* $Id: zinfo.h,v 1.27 2005-08-26 10:13:31 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
void zebraExplain_flush (ZebraExplainInfo zei, void *updateHandle);
int zebraExplain_lookup_ord (ZebraExplainInfo zei, int ord,
- const char **db, int *set, int *use);
+ int *index_type, const char **db,
+ int *set, int *use);
int zebraExplain_trav_ord(ZebraExplainInfo zei, void *handle,
int (*f)(void *handle, int ord));
-/* $Id: zrpn.c,v 1.204 2005-08-22 09:04:18 adam Exp $
+/* $Id: zrpn.c,v 1.205 2005-08-26 10:13:31 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
const char *db;
int set, use;
char term_tmp[IT_MAX_WORD];
- int su_code = 0;
- int len = key_SU_decode (&su_code, (const unsigned char *) name);
+ int ord = 0;
+ int len = key_SU_decode (&ord, (const unsigned char *) name);
zebra_term_untrans (p->zh, p->reg_type, term_tmp, name+len+1);
- yaz_log(log_level_rpn, "grep: %d %c %s", su_code, name[len], term_tmp);
+ yaz_log(log_level_rpn, "grep: %d %c %s", ord, name[len], term_tmp);
zebraExplain_lookup_ord (p->zh->reg->zei,
- su_code, &db, &set, &use);
+ ord, 0 /* index_type */, &db, &set, &use);
yaz_log(log_level_rpn, "grep: set=%d use=%d db=%s", set, use, db);
resultSetAddTerm(p->zh, p->termset, name[len], db,
-/* $Id: zsets.c,v 1.94 2005-08-19 11:04:23 adam Exp $
+/* $Id: zsets.c,v 1.95 2005-08-26 10:13:31 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
zint sysno, zebra_snippets *snippets)
{
ZebraSet sset = resultSetGet(zh, setname);
- yaz_log(YLOG_LOG, "zebra_get_hit_vector setname=%s zysno=" ZINT_FORMAT,
+ yaz_log(YLOG_DEBUG, "zebra_get_hit_vector setname=%s zysno=" ZINT_FORMAT,
setname, sysno);
if (!sset)
return ZEBRA_FAIL;
for (ol = termid->ol; ol; ol = ol->next)
{
zebra_snippets_append(snippets, key.mem[key.len-1],
- termid->reg_type,
ol->ord, termid->name);
}
}
-/* $Id: snippet.c,v 1.4 2005-06-07 15:12:39 adam Exp $
+/* $Id: snippet.c,v 1.5 2005-08-26 10:13:31 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
}
void zebra_snippets_append(zebra_snippets *l,
- zint seqno, int reg_type, int ord, const char *term)
+ zint seqno, int ord, const char *term)
{
- zebra_snippets_append_match(l, seqno, reg_type, ord, term, 0);
+ zebra_snippets_append_match(l, seqno, ord, term, 0);
}
void zebra_snippets_append_match(zebra_snippets *l,
- zint seqno, int reg_type,
- int ord, const char *term, int match)
+ zint seqno, int ord, const char *term,
+ int match)
{
struct zebra_snippet_word *w = nmem_malloc(l->nmem, sizeof(*w));
l->tail = w;
w->seqno = seqno;
- w->reg_type = reg_type;
w->ord = ord;
w->term = nmem_strdup(l->nmem, term);
w->match = match;
{
zebra_snippet_word *w;
for (w = l->front; w; w = w->next)
- yaz_log(log_level, "term=%s%s seqno=" ZINT_FORMAT " reg_type=%c "
- "ord=%d",
- w->term, (w->match ? "*" : ""), w->seqno, w->reg_type, w->ord);
+ yaz_log(log_level, "term=%s%s seqno=" ZINT_FORMAT " ord=%d",
+ w->term, (w->match ? "*" : ""), w->seqno, w->ord);
}
zebra_snippets *zebra_snippets_window(zebra_snippets *doc, zebra_snippets *hit,
while(1)
{
int window_start;
- int reg_type;
int first_seq_no_best_window = 0;
int last_seq_no_best_window = 0;
int number_best_window = 0;
for (hit_w = zebra_snippets_list(hit); hit_w; hit_w = hit_w->next)
if (hit_w->ord > ord &&
- (min_ord == 0 ||
- (hit_w->ord < min_ord && hit_w->reg_type == reg_type)))
+ (min_ord == 0 || hit_w->ord < min_ord))
{
min_ord = hit_w->ord;
- reg_type = hit_w->reg_type;
}
if (min_ord == 0)
break;
int seq_no_last = 0;
while (look_w && look_w->seqno < hit_w->seqno + window_size)
{
- if (look_w->ord == ord && look_w->reg_type == reg_type)
+ if (look_w->ord == ord)
{
seq_no_last = look_w->seqno;
number_this++;
window_start = (first_seq_no_best_window + last_seq_no_best_window -
window_size) / 2;
for (doc_w = zebra_snippets_list(doc); doc_w; doc_w = doc_w->next)
- if (doc_w->ord == ord && doc_w->reg_type == reg_type
+ if (doc_w->ord == ord
&& doc_w->seqno >= window_start
&& doc_w->seqno < window_start + window_size)
{
int match = 0;
- for (hit_w = zebra_snippets_list(hit); hit_w; hit_w = hit_w->next)
+ for (hit_w = zebra_snippets_list(hit); hit_w;
+ hit_w = hit_w->next)
{
- if (hit_w->ord == ord && hit_w->reg_type == reg_type &&
- hit_w->seqno == doc_w->seqno)
+ if (hit_w->ord == ord && hit_w->seqno == doc_w->seqno)
{
match = 1;
}
}
zebra_snippets_append_match(result, doc_w->seqno,
- doc_w->reg_type, ord,
- doc_w->term, match);
+ ord, doc_w->term, match);
}
}
return result;