1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * queryinfo.h --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * PUT COPYRIGHT NOTICE HERE
|
---|
7 | *
|
---|
8 | * $Id: queryinfo.h 398 1999-07-16 03:42:23Z sjboddie $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 |
|
---|
13 | #ifndef QUERYINFO_H
|
---|
14 | #define QUERYINFO_H
|
---|
15 |
|
---|
16 |
|
---|
17 | #include "gsdlconf.h"
|
---|
18 | #include "text_t.h"
|
---|
19 | #include "comtypes.h"
|
---|
20 |
|
---|
21 | #if defined(GSDL_USE_OBJECTSPACE)
|
---|
22 | # include <ospace\std\vector>
|
---|
23 | # include <ospace\std\algorithm>
|
---|
24 | #elif defined(GSDL_USE_STL_H)
|
---|
25 | # include <vector.h>
|
---|
26 | # if defined(GSDL_USE_ALGO_H)
|
---|
27 | # include <algo.h>
|
---|
28 | # else
|
---|
29 | # include <algorithm.h>
|
---|
30 | # endif
|
---|
31 | #else
|
---|
32 | # include <vector>
|
---|
33 | # include <algorithm>
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | // query parameters
|
---|
37 |
|
---|
38 | struct queryparamclass {
|
---|
39 | text_t combinequery;
|
---|
40 | text_t collection;
|
---|
41 |
|
---|
42 | // search_index = index+subcollection+language
|
---|
43 | text_t index;
|
---|
44 | text_t subcollection;
|
---|
45 | text_t language;
|
---|
46 |
|
---|
47 | text_t querystring;
|
---|
48 | int search_type; // 0 = boolean, 1 = ranked
|
---|
49 | int casefolding;
|
---|
50 | int stemming;
|
---|
51 | int maxdocs;
|
---|
52 |
|
---|
53 | queryparamclass ();
|
---|
54 | void clear ();
|
---|
55 | queryparamclass &operator=(const queryparamclass &q);
|
---|
56 | };
|
---|
57 |
|
---|
58 | bool operator==(const queryparamclass &x, const queryparamclass &y);
|
---|
59 | bool operator!=(const queryparamclass &x, const queryparamclass &y);
|
---|
60 |
|
---|
61 | // stream output for debugging purposes
|
---|
62 | ostream &operator<< (ostream &outs, queryparamclass &q);
|
---|
63 |
|
---|
64 |
|
---|
65 |
|
---|
66 | // term frequencies
|
---|
67 |
|
---|
68 | struct termfreqclass {
|
---|
69 | text_t termstr;
|
---|
70 | text_t termstemstr;
|
---|
71 | text_tset utf8equivterms; // kept as utf8 string for fast matching
|
---|
72 | unsigned int termfreq;
|
---|
73 |
|
---|
74 | termfreqclass ();
|
---|
75 | void clear();
|
---|
76 | termfreqclass &operator=(const termfreqclass &t);
|
---|
77 | };
|
---|
78 |
|
---|
79 | typedef vector<termfreqclass> termfreqclassarray;
|
---|
80 |
|
---|
81 | bool operator==(const termfreqclass &x, const termfreqclass &y);
|
---|
82 | bool operator!=(const termfreqclass &x, const termfreqclass &y);
|
---|
83 | bool operator<(const termfreqclass &x, const termfreqclass &y);
|
---|
84 | bool operator>(const termfreqclass &x, const termfreqclass &y);
|
---|
85 |
|
---|
86 | // stream output for debugging purposes
|
---|
87 | ostream &operator<< (ostream &outs, termfreqclass &q);
|
---|
88 |
|
---|
89 |
|
---|
90 |
|
---|
91 | // one query result
|
---|
92 |
|
---|
93 | struct docresultclass {
|
---|
94 | int docnum;
|
---|
95 | float docweight;
|
---|
96 | unsigned int num_query_terms_matched; // not available on all versions of mg
|
---|
97 | int num_phrase_match; // not available on all versions of mg
|
---|
98 |
|
---|
99 | docresultclass();
|
---|
100 | void clear ();
|
---|
101 |
|
---|
102 | // merges two result classes relating to a single docnum
|
---|
103 | docresultclass &combine(const docresultclass &d);
|
---|
104 |
|
---|
105 | docresultclass &operator=(const docresultclass &d);
|
---|
106 | };
|
---|
107 |
|
---|
108 | // stream output for debugging purposes
|
---|
109 | ostream &operator<< (ostream &outs, docresultclass &a);
|
---|
110 |
|
---|
111 |
|
---|
112 | struct ltint {
|
---|
113 | bool operator()(const int &t1, const int &t2) const
|
---|
114 | { return t1 < t2; }
|
---|
115 | };
|
---|
116 |
|
---|
117 | typedef map<int, docresultclass, ltint> docresultmap;
|
---|
118 |
|
---|
119 |
|
---|
120 |
|
---|
121 | // many document results
|
---|
122 |
|
---|
123 | struct docresultsclass {
|
---|
124 | docresultmap docset;
|
---|
125 | vector<int> docorder;
|
---|
126 |
|
---|
127 | docresultsclass ();
|
---|
128 | void clear ();
|
---|
129 | void docnum_order();
|
---|
130 |
|
---|
131 | void combine_and (const docresultsclass &d);
|
---|
132 | void combine_or (const docresultsclass &d);
|
---|
133 | void combine_not (const docresultsclass &d);
|
---|
134 |
|
---|
135 | docresultsclass &operator=(const docresultsclass &d);
|
---|
136 | };
|
---|
137 |
|
---|
138 |
|
---|
139 |
|
---|
140 |
|
---|
141 | // query results
|
---|
142 |
|
---|
143 | struct queryresultsclass {
|
---|
144 | queryresultsclass () {clear();}
|
---|
145 |
|
---|
146 | int docs_matched; // not available on all versions of mg
|
---|
147 | isapprox is_approx;
|
---|
148 | // bool is_approx; // not available on all versions of mg
|
---|
149 |
|
---|
150 | bool postprocessed; // whether this record has been post-processed
|
---|
151 |
|
---|
152 | docresultsclass docs;
|
---|
153 | termfreqclassarray orgterms; // terms before they are sorted and uniqued
|
---|
154 | termfreqclassarray terms;
|
---|
155 | text_tset termvariants;
|
---|
156 |
|
---|
157 | void clear ();
|
---|
158 | queryresultsclass &operator=(const queryresultsclass &q);
|
---|
159 |
|
---|
160 | void sortuniqqueryterms();
|
---|
161 | };
|
---|
162 |
|
---|
163 | // stream output for debugging purposes
|
---|
164 | ostream &operator<< (ostream &outs, queryresultsclass &q);
|
---|
165 |
|
---|
166 |
|
---|
167 | #endif
|
---|