From 7e928bc31abe214023a0fc61d77b092f4ee9ba7e Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 4 Oct 1995 12:55:16 +0000 Subject: [PATCH] Bug fix in ranked search. Use=Any keys inserted. --- index/extract.c | 22 ++++++++++++++++++++-- index/zrpn.c | 44 ++++++++++++++++++++++++++++++++++++-------- 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/index/extract.c b/index/extract.c index 0db63cc..718ef0c 100644 --- a/index/extract.c +++ b/index/extract.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: extract.c,v $ - * Revision 1.18 1995-10-04 09:37:08 quinn + * Revision 1.19 1995-10-04 12:55:16 adam + * Bug fix in ranked search. Use=Any keys inserted. + * + * Revision 1.18 1995/10/04 09:37:08 quinn * Fixed bug. * * Revision 1.17 1995/10/03 14:28:57 adam @@ -219,6 +222,21 @@ static void wordAdd (const RecWord *p) kused += sizeof(key); } +static void wordAddAny (const RecWord *p) +{ + if (p->attrSet != 1 && p->attrUse != 1016) + { + RecWord w; + + memcpy (&w, p, sizeof(w)); + w.attrSet = 1; + w.attrUse = 1016; + wordAdd (&w); + } + wordAdd (p); +} + + #define FILE_READ_BUF 1 #if FILE_READ_BUF static char *file_buf; @@ -334,7 +352,7 @@ void file_extract (int cmd, const char *fname, const char *kname) } extractCtrl.subType = ""; extractCtrl.init = wordInit; - extractCtrl.add = wordAdd; + extractCtrl.add = wordAddAny; #if FILE_READ_BUF file_read_start (extractCtrl.fd); #endif diff --git a/index/zrpn.c b/index/zrpn.c index f57400e..9d12e03 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zrpn.c,v $ - * Revision 1.16 1995-10-02 16:24:40 adam + * Revision 1.17 1995-10-04 12:55:17 adam + * Bug fix in ranked search. Use=Any keys inserted. + * + * Revision 1.16 1995/10/02 16:24:40 adam * Use attribute actually used in search requests. * * Revision 1.15 1995/10/02 15:18:52 adam @@ -338,21 +341,31 @@ static int trunc_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, const char *info; AttrType truncation; int truncation_value; + AttrType use; + int use_value; + attr_init (&use, zapt, 1); + use_value = attr_find (&use); + logf (LOG_DEBUG, "use value %d", truncation_value); attr_init (&truncation, zapt, 5); truncation_value = attr_find (&truncation); logf (LOG_DEBUG, "truncation value %d", truncation_value); + + if (use_value == -1) + use_value = 1016; + i = index_word_prefix (term_dict, 1, use_value); + switch (truncation_value) { case -1: /* not specified */ case 100: /* do not truncate */ - strcpy (term_dict, term_sub); + strcat (term_dict, term_sub); logf (LOG_DEBUG, "dict_lookup: %s", term_dict); if ((info = dict_lookup (zi->wordDict, term_dict))) add_isam_p (info); break; case 1: /* right truncation */ - strcpy (term_dict, term_sub); + strcat (term_dict, term_sub); strcat (term_dict, ".*"); dict_lookup_grep (zi->wordDict, term_dict, 0, grep_handle); break; @@ -361,7 +374,7 @@ static int trunc_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, zi->errCode = 120; return -1; case 101: /* process # in term */ - for (j = 0, i = 0; term_sub[i] && i < 2; i++) + for (j = strlen(term_dict), i = 0; term_sub[i] && i < 2; i++) term_dict[j++] = term_sub[i]; for (; term_sub[i]; i++) if (term_sub[i] == '#') @@ -375,7 +388,7 @@ static int trunc_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, dict_lookup_grep (zi->wordDict, term_dict, 0, grep_handle); break; case 102: /* regular expression */ - strcpy (term_dict, term_sub); + strcat (term_dict, term_sub); dict_lookup_grep (zi->wordDict, term_dict, 0, grep_handle); break; } @@ -384,6 +397,7 @@ static int trunc_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, return 0; } +#if 0 static void field_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, char *termz) { @@ -405,7 +419,21 @@ static void field_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, termz[i] = index_char_cvt (term->u.general->buf[j]); termz[i] = '\0'; } +#else +static void trans_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, + char *termz) +{ + size_t i, sizez; + Z_Term *term = zapt->term; + sizez = term->u.general->len; + if (sizez > IT_MAX_WORD) + sizez = IT_MAX_WORD; + for (i = 0; i < sizez; i++) + termz[i] = index_char_cvt (term->u.general->buf[i]); + termz[i] = '\0'; +} +#endif static RSET rpn_search_APT_relevance (ZServerInfo *zi, Z_AttributesPlusTerm *zapt) @@ -426,7 +454,7 @@ static RSET rpn_search_APT_relevance (ZServerInfo *zi, zi->errCode = 124; return NULL; } - field_term (zi, zapt, termz); + trans_term (zi, zapt, termz); isam_p_indx = 0; /* global, set by trunc_term - see below */ while (1) { @@ -464,7 +492,7 @@ static RSET rpn_search_APT_word (ZServerInfo *zi, zi->errCode = 124; return NULL; } - field_term (zi, zapt, termz); + trans_term (zi, zapt, termz); isam_p_indx = 0; /* global, set by trunc_term - see below */ if (trunc_term (zi, zapt, termz, &isam_positions)) return NULL; @@ -494,7 +522,7 @@ static RSET rpn_search_APT_phrase (ZServerInfo *zi, zi->errCode = 124; return NULL; } - field_term (zi, zapt, termz); + trans_term (zi, zapt, termz); isam_p_indx = 0; /* global, set by trunc_term - see below */ if (trunc_term (zi, zapt, termz, &isam_positions)) return NULL; -- 1.7.10.4