source: main/tags/2.10/gsdl/src/colservr/queryinfo.h@ 32704

Last change on this file since 32704 was 534, checked in by sjboddie, 25 years ago

added gpl notice

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/**********************************************************************
2 *
3 * queryinfo.h --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * $Id: queryinfo.h 534 1999-09-07 04:57:43Z sjboddie $
25 *
26 *********************************************************************/
27
28
29#ifndef QUERYINFO_H
30#define QUERYINFO_H
31
32
33#include "gsdlconf.h"
34#include "text_t.h"
35#include "comtypes.h"
36
37#if defined(GSDL_USE_OBJECTSPACE)
38# include <ospace\std\vector>
39# include <ospace\std\algorithm>
40#elif defined(GSDL_USE_STL_H)
41# include <vector.h>
42# if defined(GSDL_USE_ALGO_H)
43# include <algo.h>
44# else
45# include <algorithm.h>
46# endif
47#else
48# include <vector>
49# include <algorithm>
50#endif
51
52// query parameters
53
54struct queryparamclass {
55 text_t combinequery;
56 text_t collection;
57
58 // search_index = index+subcollection+language
59 text_t index;
60 text_t subcollection;
61 text_t language;
62
63 text_t querystring;
64 int search_type; // 0 = boolean, 1 = ranked
65 int match_mode; // 0 = some, 1 = all
66 int casefolding;
67 int stemming;
68 int maxdocs;
69
70 queryparamclass ();
71 void clear ();
72 queryparamclass &operator=(const queryparamclass &q);
73};
74
75bool operator==(const queryparamclass &x, const queryparamclass &y);
76bool operator!=(const queryparamclass &x, const queryparamclass &y);
77
78// stream output for debugging purposes
79ostream &operator<< (ostream &outs, queryparamclass &q);
80
81
82
83// term frequencies
84
85struct termfreqclass {
86 text_t termstr;
87 text_t termstemstr;
88 text_tset utf8equivterms; // kept as utf8 string for fast matching
89 unsigned int termfreq;
90
91 termfreqclass ();
92 void clear();
93 termfreqclass &operator=(const termfreqclass &t);
94};
95
96typedef vector<termfreqclass> termfreqclassarray;
97
98bool operator==(const termfreqclass &x, const termfreqclass &y);
99bool operator!=(const termfreqclass &x, const termfreqclass &y);
100bool operator<(const termfreqclass &x, const termfreqclass &y);
101bool operator>(const termfreqclass &x, const termfreqclass &y);
102
103// stream output for debugging purposes
104ostream &operator<< (ostream &outs, termfreqclass &q);
105
106
107
108// one query result
109
110struct docresultclass {
111 int docnum;
112 float docweight;
113 unsigned int num_query_terms_matched; // not available on all versions of mg
114 int num_phrase_match; // not available on all versions of mg
115
116 docresultclass();
117 ~docresultclass() {}
118 void clear ();
119
120 // merges two result classes relating to a single docnum
121 docresultclass &combine(const docresultclass &d);
122
123 docresultclass &operator=(const docresultclass &d);
124};
125
126bool operator==(const docresultclass &x, const docresultclass &y);
127bool operator<(const docresultclass &x, const docresultclass &y);
128
129
130// stream output for debugging purposes
131ostream &operator<< (ostream &outs, docresultclass &a);
132
133
134struct ltint {
135 bool operator()(const int &t1, const int &t2) const
136 { return t1 < t2; }
137};
138
139typedef map<int, docresultclass, ltint> docresultmap;
140
141
142
143// many document results
144
145struct docresultsclass {
146 docresultmap docset;
147 vector<int> docorder;
148
149 docresultsclass ();
150 void clear ();
151 void docnum_order();
152
153 void combine_and (const docresultsclass &d);
154 void combine_or (const docresultsclass &d);
155 void combine_not (const docresultsclass &d);
156
157 docresultsclass &operator=(const docresultsclass &d);
158};
159
160
161
162
163// query results
164
165struct queryresultsclass {
166 queryresultsclass () {clear();}
167
168 int docs_matched; // not available on all versions of mg
169 isapprox is_approx;
170 // bool is_approx; // not available on all versions of mg
171
172 bool postprocessed; // whether this record has been post-processed
173
174 docresultsclass docs;
175 termfreqclassarray orgterms; // terms before they are sorted and uniqued
176 termfreqclassarray terms;
177 text_tset termvariants;
178
179 void clear ();
180 queryresultsclass &operator=(const queryresultsclass &q);
181
182 void sortuniqqueryterms();
183};
184
185// stream output for debugging purposes
186ostream &operator<< (ostream &outs, queryresultsclass &q);
187
188
189#endif
Note: See TracBrowser for help on using the repository browser.