1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * mgsearch.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: mgsearch.h 612 1999-09-21 11:59:26Z sjboddie $
|
---|
25 | *
|
---|
26 | *********************************************************************/
|
---|
27 |
|
---|
28 |
|
---|
29 | #ifndef MGSEARCH_H
|
---|
30 | #define MGSEARCH_H
|
---|
31 |
|
---|
32 |
|
---|
33 | #include "text_t.h"
|
---|
34 | #include "querycache.h"
|
---|
35 |
|
---|
36 | #define RESULTCACHESIZE 10
|
---|
37 | #define MAXNUMDOCS 1000000
|
---|
38 | #define MAXNUMTERMS 100
|
---|
39 |
|
---|
40 | class mgsearchclass {
|
---|
41 | public:
|
---|
42 | mgsearchclass ();
|
---|
43 | virtual ~mgsearchclass ();
|
---|
44 |
|
---|
45 | // the index directory must be set before any searching
|
---|
46 | // is done
|
---|
47 | void setcollectdir (const text_t &thecollectdir);
|
---|
48 |
|
---|
49 | // you only need to use this function before doing any stemming
|
---|
50 | // casefolding and stemming will be set if values for them are
|
---|
51 | // provided (0 or 1).
|
---|
52 | // makeindexcurrent returns true if it was able to load the database
|
---|
53 | bool makeindexcurrent (const text_t &index, const text_t &subcollection,
|
---|
54 | const text_t &language, const text_t &collection,
|
---|
55 | int casefolding = -1, int stemming = -1);
|
---|
56 |
|
---|
57 | // stem word uses the values set in the last call to makeindexcurrent
|
---|
58 | // to stem the word. It is assumed that word is in unicode
|
---|
59 | text_t stemword (const text_t &word);
|
---|
60 | text_t stemword (text_t::const_iterator here, text_t::const_iterator end);
|
---|
61 |
|
---|
62 | // the search results are returned in queryresults
|
---|
63 | // search returns 'true' if it was able to do a search
|
---|
64 | bool search(const queryparamclass &queryparams,
|
---|
65 | queryresultsclass &queryresults);
|
---|
66 |
|
---|
67 | // the document text for 'docnum' is placed in 'output'
|
---|
68 | // docTargetDocument returns 'true' if it was able to
|
---|
69 | // try to get a document
|
---|
70 | // collection is needed to see if an index from the
|
---|
71 | // collection is loaded. If no index has been loaded
|
---|
72 | // defaultindex is needed to load one
|
---|
73 | bool docTargetDocument(const text_t &defaultindex,
|
---|
74 | const text_t &defaultsubcollection,
|
---|
75 | const text_t &defaultlanguage,
|
---|
76 | const text_t &collection,
|
---|
77 | int docnum,
|
---|
78 | text_t &output);
|
---|
79 |
|
---|
80 | // same as docTargetDocument except the document is returned
|
---|
81 | // in its raw form. UDoc remains the property of mg and may
|
---|
82 | // be destroyed on the next call to mg.
|
---|
83 | bool mgdocument (const text_t &defaultindex,
|
---|
84 | const text_t &defaultsubcollection,
|
---|
85 | const text_t &defaultlanguage,
|
---|
86 | const text_t &collection,
|
---|
87 | int docnum,
|
---|
88 | char *&UDoc, int &ULen);
|
---|
89 |
|
---|
90 | protected:
|
---|
91 | querycache *cache;
|
---|
92 | text_t collectdir; // the collection directory
|
---|
93 |
|
---|
94 | void setsearchmode (const queryparamclass &queryparams);
|
---|
95 | void submitquery (const queryparamclass &queryparams);
|
---|
96 | void getresults (const queryparamclass &queryparams, queryresultsclass &queryresults);
|
---|
97 |
|
---|
98 | virtual void filterquery (text_t &ttquerystring);
|
---|
99 | };
|
---|
100 |
|
---|
101 |
|
---|
102 | #endif
|
---|