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 114 1999-01-19 01:38:20Z 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 | unsigned int termfreq;
|
---|
66 |
|
---|
67 | termfreqclass &operator=(const termfreqclass &t);
|
---|
68 | };
|
---|
69 |
|
---|
70 | bool operator==(const termfreqclass &x, const termfreqclass &y);
|
---|
71 | bool operator!=(const termfreqclass &x, const termfreqclass &y);
|
---|
72 | bool operator<(const termfreqclass &x, const termfreqclass &y);
|
---|
73 | bool operator>(const termfreqclass &x, const termfreqclass &y);
|
---|
74 |
|
---|
75 | // stream output for debugging purposes
|
---|
76 | ostream &operator<< (ostream &outs, termfreqclass &q);
|
---|
77 |
|
---|
78 |
|
---|
79 |
|
---|
80 | // one query result
|
---|
81 |
|
---|
82 | class docresultclass
|
---|
83 | {
|
---|
84 | public:
|
---|
85 | docresultclass(void) {docnum=-1;docweight=0.0;};
|
---|
86 | ~docresultclass(void) {};
|
---|
87 |
|
---|
88 | int docnum;
|
---|
89 | float docweight;
|
---|
90 | };
|
---|
91 |
|
---|
92 | // stream output for debugging purposes
|
---|
93 | ostream &operator<< (ostream &outs, docresultclass &a);
|
---|
94 |
|
---|
95 |
|
---|
96 |
|
---|
97 | // query results
|
---|
98 |
|
---|
99 | class queryresultsclass
|
---|
100 | {
|
---|
101 | public:
|
---|
102 | vector<docresultclass> docs;
|
---|
103 | vector<termfreqclass> terms;
|
---|
104 | vector<text_t> termvariants;
|
---|
105 |
|
---|
106 | void clear ();
|
---|
107 | queryresultsclass &operator=(const queryresultsclass &q);
|
---|
108 |
|
---|
109 | int getnumdocs () {return docs.size();}
|
---|
110 | int getnumterms () {return terms.size();}
|
---|
111 |
|
---|
112 | void sortqueryterms();
|
---|
113 | void uniqqueryterms();
|
---|
114 | };
|
---|
115 |
|
---|
116 | // stream output for debugging purposes
|
---|
117 | ostream &operator<< (ostream &outs, queryresultsclass &q);
|
---|
118 |
|
---|
119 |
|
---|
120 | #endif
|
---|