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 326 1999-07-01 03:56:17Z rjmcnab $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 |
|
---|
13 | #ifndef QUERYINFO_H
|
---|
14 | #define QUERYINFO_H
|
---|
15 |
|
---|
16 |
|
---|
17 | #include "gsdlconf.h"
|
---|
18 | #include "text_t.h"
|
---|
19 |
|
---|
20 | #if defined(GSDL_USE_OBJECTSPACE)
|
---|
21 | # include <ospace\std\vector>
|
---|
22 | # include <ospace\std\algorithm>
|
---|
23 | #elif defined(GSDL_USE_STL_H)
|
---|
24 | # include <vector.h>
|
---|
25 | # if defined(GSDL_USE_ALGO_H)
|
---|
26 | # include <algo.h>
|
---|
27 | # else
|
---|
28 | # include <algorithm.h>
|
---|
29 | # endif
|
---|
30 | #else
|
---|
31 | # include <vector>
|
---|
32 | # include <algorithm>
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | // query parameters
|
---|
36 |
|
---|
37 | class queryparamclass
|
---|
38 | {
|
---|
39 | public:
|
---|
40 | text_t collection;
|
---|
41 | text_t search_index;
|
---|
42 | text_t querystring;
|
---|
43 | int search_type; // 0 = boolean, 1 = ranked
|
---|
44 | int casefolding;
|
---|
45 | int stemming;
|
---|
46 | int maxdocs;
|
---|
47 |
|
---|
48 | queryparamclass &operator=(const queryparamclass &q);
|
---|
49 | };
|
---|
50 |
|
---|
51 | bool operator==(const queryparamclass &x, const queryparamclass &y);
|
---|
52 | bool operator!=(const queryparamclass &x, const queryparamclass &y);
|
---|
53 |
|
---|
54 | // stream output for debugging purposes
|
---|
55 | ostream &operator<< (ostream &outs, queryparamclass &q);
|
---|
56 |
|
---|
57 |
|
---|
58 |
|
---|
59 | // term frequencies
|
---|
60 |
|
---|
61 | class termfreqclass
|
---|
62 | {
|
---|
63 | public:
|
---|
64 | text_t termstr;
|
---|
65 | text_t termstemstr;
|
---|
66 | text_tset utf8equivterms; // kept as utf8 string for fast matching
|
---|
67 | unsigned int termfreq;
|
---|
68 |
|
---|
69 | termfreqclass &operator=(const termfreqclass &t);
|
---|
70 | };
|
---|
71 |
|
---|
72 | bool operator==(const termfreqclass &x, const termfreqclass &y);
|
---|
73 | bool operator!=(const termfreqclass &x, const termfreqclass &y);
|
---|
74 | bool operator<(const termfreqclass &x, const termfreqclass &y);
|
---|
75 | bool operator>(const termfreqclass &x, const termfreqclass &y);
|
---|
76 |
|
---|
77 | // stream output for debugging purposes
|
---|
78 | ostream &operator<< (ostream &outs, termfreqclass &q);
|
---|
79 |
|
---|
80 |
|
---|
81 |
|
---|
82 | // one query result
|
---|
83 |
|
---|
84 | class docresultclass {
|
---|
85 | public:
|
---|
86 | docresultclass(void) {
|
---|
87 | docnum=-1; docweight=0.0; num_query_terms_matched=0;
|
---|
88 | query_phrase_match=false;
|
---|
89 | };
|
---|
90 | ~docresultclass(void) {};
|
---|
91 |
|
---|
92 | int docnum;
|
---|
93 | float docweight;
|
---|
94 | unsigned int num_query_terms_matched; // not available on all versions of mg
|
---|
95 | bool query_phrase_match; // not available on all versions of mg
|
---|
96 | };
|
---|
97 |
|
---|
98 | // stream output for debugging purposes
|
---|
99 | ostream &operator<< (ostream &outs, docresultclass &a);
|
---|
100 |
|
---|
101 |
|
---|
102 |
|
---|
103 | // query results
|
---|
104 |
|
---|
105 | class queryresultsclass {
|
---|
106 | public:
|
---|
107 | queryresultsclass () {clear();}
|
---|
108 |
|
---|
109 | bool docs_matched_set;
|
---|
110 | int docs_matched; // not available on all versions of mg
|
---|
111 | bool is_approx; // not available on all versions of mg
|
---|
112 |
|
---|
113 | bool postprocessed; // whether this record has been post-processed
|
---|
114 |
|
---|
115 | vector<docresultclass> docs;
|
---|
116 | vector<termfreqclass> orgterms; // terms before they are sorted and uniqued
|
---|
117 | vector<termfreqclass> terms;
|
---|
118 | text_tarray termvariants;
|
---|
119 |
|
---|
120 | void clear ();
|
---|
121 | queryresultsclass &operator=(const queryresultsclass &q);
|
---|
122 |
|
---|
123 | int getnumdocs () {
|
---|
124 | if (docs_matched_set) return docs_matched;
|
---|
125 | else return docs.size();
|
---|
126 | }
|
---|
127 | int getnumterms () {return terms.size();}
|
---|
128 |
|
---|
129 | void sortuniqqueryterms();
|
---|
130 | };
|
---|
131 |
|
---|
132 | // stream output for debugging purposes
|
---|
133 | ostream &operator<< (ostream &outs, queryresultsclass &q);
|
---|
134 |
|
---|
135 |
|
---|
136 | #endif
|
---|