More work on relevance feedback.
[idzebra-moved-to-github.git] / index / kcompare.c
1 /*
2  * Copyright (C) 1994-1995, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: kcompare.c,v $
7  * Revision 1.5  1995-09-11 13:09:34  adam
8  * More work on relevance feedback.
9  *
10  * Revision 1.4  1995/09/08  14:52:27  adam
11  * Minor changes. Dictionary is lower case now.
12  *
13  * Revision 1.3  1995/09/07  13:58:36  adam
14  * New parameter: result-set file descriptor (RSFD) to support multiple
15  * positions within the same result-set.
16  * Boolean operators: and, or, not implemented.
17  * Result-set references.
18  *
19  * Revision 1.2  1995/09/06  16:11:17  adam
20  * Option: only one word key per file.
21  *
22  * Revision 1.1  1995/09/04  09:10:36  adam
23  * More work on index add/del/update.
24  * Merge sort implemented.
25  * Initial work on z39 server.
26  *
27  */
28
29 #include <stdlib.h>
30 #include <string.h>
31 #include <stdio.h>
32 #include <ctype.h>
33 #include <assert.h>
34
35 #include "index.h"
36
37 void key_logdump (int logmask, const void *p)
38 {
39     struct it_key key;
40
41     memcpy (&key, p, sizeof(key));
42 #if IT_KEY_HAVE_SEQNO
43     logf (logmask, "%7d s=%-3d", key.sysno, key.seqno);
44 #else
45     logf (logmask, "%7d f=%-3d", key.sysno, key.freq);
46 #endif
47 }
48
49 int key_compare (const void *p1, const void *p2)
50 {
51     struct it_key i1, i2;
52     memcpy (&i1, p1, sizeof(i1));
53     memcpy (&i2, p2, sizeof(i2));
54     if (i1.sysno != i2.sysno)
55     {
56         if (i1.sysno > i2.sysno)
57             return 2;
58         else
59             return -2;
60     }
61 #if IT_KEY_HAVE_SEQNO
62     if (i1.seqno != i2.seqno)
63     {
64         if (i1.seqno > i2.seqno)
65             return 1;
66         else
67             return -1;
68     }
69 #else
70     if (i1.freq != i2.freq)
71     {
72         if (i1.freq > i2.freq)
73             return 1;
74         else
75             return -1;
76     }
77 #endif
78 #if IT_KEY_HAVE_FIELD
79     if (i1.field != i2.field)
80     {
81         if (i1.field > i2.field)
82             return 1;
83         else
84             return -1;
85     }
86 #endif
87     return 0;
88 }
89
90 int index_char_cvt (int c)
91 {
92     return tolower (c);
93 }