source: trunk/gsdl/src/colservr/queryinfo.h@ 2545

Last change on this file since 2545 was 1319, checked in by kjm18, 24 years ago

added level info to queryparamclass for mgpp collections

  • 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 *********************************************************************/
25
26
27#ifndef QUERYINFO_H
28#define QUERYINFO_H
29
30
31#include "gsdlconf.h"
32#include "text_t.h"
33#include "comtypes.h"
34
35#if defined(GSDL_USE_OBJECTSPACE)
36# include <ospace\std\vector>
37# include <ospace\std\algorithm>
38#elif defined(GSDL_USE_STL_H)
39# include <vector.h>
40# if defined(GSDL_USE_ALGO_H)
41# include <algo.h>
42# else
43# include <algorithm.h>
44# endif
45#else
46# include <vector>
47# include <algorithm>
48#endif
49
50// query parameters
51
52struct queryparamclass {
53 text_t combinequery;
54 text_t collection;
55
56 // search_index = index+subcollection+language
57 text_t index;
58 text_t subcollection;
59 text_t language;
60 text_t level; // for new mg stuff
61 text_t querystring;
62 int search_type; // 0 = boolean, 1 = ranked
63 int match_mode; // 0 = some, 1 = all
64 int casefolding;
65 int stemming;
66 int maxdocs;
67
68 queryparamclass ();
69 void clear ();
70 queryparamclass &operator=(const queryparamclass &q);
71};
72
73bool operator==(const queryparamclass &x, const queryparamclass &y);
74bool operator!=(const queryparamclass &x, const queryparamclass &y);
75
76// stream output for debugging purposes
77ostream &operator<< (ostream &outs, queryparamclass &q);
78
79
80
81// term frequencies
82
83struct termfreqclass {
84 text_t termstr;
85 text_t termstemstr;
86 text_tset utf8equivterms; // kept as utf8 string for fast matching
87 unsigned int termfreq;
88
89 termfreqclass ();
90 void clear();
91 termfreqclass &operator=(const termfreqclass &t);
92};
93
94typedef vector<termfreqclass> termfreqclassarray;
95
96bool operator==(const termfreqclass &x, const termfreqclass &y);
97bool operator!=(const termfreqclass &x, const termfreqclass &y);
98bool operator<(const termfreqclass &x, const termfreqclass &y);
99bool operator>(const termfreqclass &x, const termfreqclass &y);
100
101// stream output for debugging purposes
102ostream &operator<< (ostream &outs, termfreqclass &q);
103
104
105
106// one query result
107
108struct docresultclass {
109 int docnum;
110 float docweight;
111 unsigned int num_query_terms_matched; // not available on all versions of mg
112 int num_phrase_match; // not available on all versions of mg
113
114 docresultclass();
115 ~docresultclass() {}
116 void clear ();
117
118 // merges two result classes relating to a single docnum
119 docresultclass &combine(const docresultclass &d);
120
121 docresultclass &operator=(const docresultclass &d);
122};
123
124bool operator==(const docresultclass &x, const docresultclass &y);
125bool operator<(const docresultclass &x, const docresultclass &y);
126
127
128// stream output for debugging purposes
129ostream &operator<< (ostream &outs, docresultclass &a);
130
131
132struct ltint {
133 bool operator()(const int &t1, const int &t2) const
134 { return t1 < t2; }
135};
136
137typedef map<int, docresultclass, ltint> docresultmap;
138
139
140
141// many document results
142
143struct docresultsclass {
144 docresultmap docset;
145 vector<int> docorder;
146
147 docresultsclass ();
148 void clear ();
149 void docnum_order();
150
151 void combine_and (const docresultsclass &d);
152 void combine_or (const docresultsclass &d);
153 void combine_not (const docresultsclass &d);
154
155 docresultsclass &operator=(const docresultsclass &d);
156};
157
158
159
160
161// query results
162
163struct queryresultsclass {
164 queryresultsclass () {clear();}
165
166 int docs_matched; // not available on all versions of mg
167 isapprox is_approx;
168 // bool is_approx; // not available on all versions of mg
169
170 bool postprocessed; // whether this record has been post-processed
171
172 docresultsclass docs;
173 termfreqclassarray orgterms; // terms before they are sorted and uniqued
174 termfreqclassarray terms;
175 text_tset termvariants;
176
177 void clear ();
178 queryresultsclass &operator=(const queryresultsclass &q);
179
180 void sortuniqqueryterms();
181};
182
183// stream output for debugging purposes
184ostream &operator<< (ostream &outs, queryresultsclass &q);
185
186
187#endif
Note: See TracBrowser for help on using the repository browser.