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

Last change on this file since 15757 was 12868, checked in by kjdon, 18 years ago

AccentFolding patch, thanks to Juan Grigera. added accentfolding to queryparamclass

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 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 accentfolding;
67 int maxdocs;
68 int maxnumeric;
69 text_t filterstring; // Filter specified (currently only used by Lucene)
70 text_t sortfield; // Field to use for sorting result set (currently used by lucene)
71 text_t fuzziness; // Search fuzziness amount between 0.0 and 1.0 (only used by Lucene)
72
73 int startresults;
74 int endresults;
75
76 queryparamclass ();
77 void clear ();
78 queryparamclass &operator=(const queryparamclass &q);
79};
80
81bool operator==(const queryparamclass &x, const queryparamclass &y);
82bool operator!=(const queryparamclass &x, const queryparamclass &y);
83
84// stream output for debugging purposes
85ostream &operator<< (ostream &outs, queryparamclass &q);
86
87
88
89// term frequencies
90
91struct termfreqclass {
92 text_t termstr;
93 text_t termstemstr;
94 text_tset utf8equivterms; // kept as utf8 string for fast matching
95 unsigned int termfreq;
96
97 termfreqclass ();
98 void clear();
99 termfreqclass &operator=(const termfreqclass &t);
100};
101
102typedef vector<termfreqclass> termfreqclassarray;
103
104bool operator==(const termfreqclass &x, const termfreqclass &y);
105bool operator!=(const termfreqclass &x, const termfreqclass &y);
106bool operator<(const termfreqclass &x, const termfreqclass &y);
107bool operator>(const termfreqclass &x, const termfreqclass &y);
108
109// stream output for debugging purposes
110ostream &operator<< (ostream &outs, termfreqclass &q);
111
112
113
114// one query result
115
116struct docresultclass {
117 int docnum;
118 float docweight;
119 unsigned int num_query_terms_matched; // not available on all versions of mg
120 int num_phrase_match; // not available on all versions of mg
121
122 docresultclass();
123 ~docresultclass() {}
124 void clear ();
125
126 // merges two result classes relating to a single docnum
127 docresultclass &combine(const docresultclass &d);
128
129 docresultclass &operator=(const docresultclass &d);
130};
131
132bool operator==(const docresultclass &x, const docresultclass &y);
133bool operator<(const docresultclass &x, const docresultclass &y);
134
135
136// stream output for debugging purposes
137ostream &operator<< (ostream &outs, docresultclass &a);
138
139
140struct ltint {
141 bool operator()(const int &t1, const int &t2) const
142 { return t1 < t2; }
143};
144
145typedef map<int, docresultclass, ltint> docresultmap;
146
147
148
149// many document results
150
151struct docresultsclass {
152 docresultmap docset;
153 vector<int> docorder;
154
155 docresultsclass ();
156 void clear ();
157 void docnum_order();
158
159 void combine_and (const docresultsclass &d);
160 void combine_or (const docresultsclass &d);
161 void combine_not (const docresultsclass &d);
162
163 docresultsclass &operator=(const docresultsclass &d);
164};
165
166
167
168
169// query results
170
171struct queryresultsclass {
172 queryresultsclass () {clear();}
173
174 text_t error_message; // Currently only used by Lucene
175 int docs_matched; // not available on all versions of mg
176 isapprox is_approx;
177 // bool is_approx; // not available on all versions of mg
178 bool syntax_error; // whether the query string was invalid
179 bool postprocessed; // whether this record has been post-processed
180
181 docresultsclass docs;
182 termfreqclassarray orgterms; // terms before they are sorted and uniqued
183 termfreqclassarray terms;
184 text_tset termvariants;
185 text_tset stopwords;
186
187 void clear ();
188 queryresultsclass &operator=(const queryresultsclass &q);
189
190 void sortuniqqueryterms();
191};
192
193// stream output for debugging purposes
194ostream &operator<< (ostream &outs, queryresultsclass &q);
195
196
197#endif
Note: See TracBrowser for help on using the repository browser.