Changeset 91 for trunk/gsdl/src/library/mgsearch.cpp
- Timestamp:
- 1998-12-30T16:50:37+13:00 (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/library/mgsearch.cpp
r32 r91 27 27 #include "mgsearch.h" 28 28 #include "locateinfo.h" 29 #include "gsdlunicode.h" 30 #include "unitool.h" 31 29 32 30 33 ///////////// … … 82 85 float Weight, void *info) { 83 86 87 // convert term from utf8 to unicode 88 text_t term; 89 utf8inconvertclass inconvert; 90 convertclass::status_t status; 91 inconvert.reset (); 92 inconvert.setinput (Word, ULen); 93 inconvert.convert (term, status); 94 84 95 queryresultsclass *queryresults = (queryresultsclass *)info; 85 queryresults->termvariants.push_back( Word);96 queryresults->termvariants.push_back(term); 86 97 87 98 return 0; … … 93 104 text_t *output = (text_t *)info; 94 105 if (output == NULL) return 0; 95 96 output->setcarr(Word, ULen); 106 output->clear(); 107 108 utf8inconvertclass inconvert; 109 convertclass::status_t status; 110 inconvert.reset (); 111 inconvert.setinput (Word, ULen); 112 inconvert.convert (*output, status); 97 113 98 114 // replace all control-Cs with spaces 99 115 text_t::iterator here = output->begin(); 100 116 text_t::iterator end = output->end(); 101 while (here != end) 102 { 103 if (*here == '\x3') *here = ' '; 104 here++; 105 } 117 while (here != end) { 118 if (*here == '\x3') *here = ' '; 119 here++; 120 } 106 121 107 122 return 0; … … 129 144 130 145 131 void mgsearchclass::set indexhome (const text_t &theindexhome)132 { 133 indexhome = theindexhome;146 void mgsearchclass::setcollectdir (const text_t &thecollectdir) 147 { 148 collectdir = thecollectdir; 134 149 } 135 150 136 151 137 152 bool mgsearchclass::search(const queryparamclass &queryparams, 138 153 queryresultsclass &queryresults) 139 154 { 140 155 bool databaseloaded = true; … … 146 161 // first check the cache 147 162 if (cache->find(queryparams, queryresults)) 148 { 149 return true; 150 } 163 return true; 151 164 152 165 // make sure there is a query to be processed … … 154 167 text_t::const_iterator queryend = queryparams.querystring.end(); 155 168 while (queryhere != queryend) { 156 if (((*queryhere >= 65) && (*queryhere <= 90)) || 157 ((*queryhere >= 97) && (*queryhere <= 122)) || 158 ((*queryhere >= 192) && (*queryhere <= 214)) || 159 ((*queryhere >= 216) && (*queryhere <= 246)) || 160 ((*queryhere >= 248) && (*queryhere <= 255)) || 161 ((*queryhere >= '0') && (*queryhere <= '9'))) break; 169 if (is_unicode_letdig (*queryhere)) break; 162 170 queryhere++; 163 171 } … … 169 177 170 178 171 172 179 // get the names of the index and text suffixes 173 text_t ttidxsuffix, tttxtsuffix; 174 getindexsuffix (queryparams.search_index, 175 queryparams.collection, ttidxsuffix); 176 gettextsuffix (queryparams.collection, tttxtsuffix); 177 char *idxsuffix = ttidxsuffix.getcstr(); assert (idxsuffix != NULL); 178 char *txtsuffix = tttxtsuffix.getcstr(); assert (txtsuffix != NULL); 180 char *idxsuffix = (getindexsuffix (queryparams.collection, 181 queryparams.search_index)).getcstr(); 182 assert (idxsuffix != NULL); 183 char *txtsuffix = (gettextsuffix (queryparams.collection)).getcstr(); 184 assert (txtsuffix != NULL); 179 185 180 186 #ifdef __WIN32__ 181 char *c indexhome = (indexhome+"\\").getcstr(); assert (cindexhome!= NULL);187 char *ccollectdir = (collectdir+"\\").getcstr(); assert (ccollectdir != NULL); 182 188 #else 183 char *c indexhome = indexhome.getcstr(); assert (cindexhome!= NULL);189 char *ccollectdir = collectdir.getcstr(); assert (ccollectdir != NULL); 184 190 #endif 185 191 186 if (load_database(c indexhome, idxsuffix, txtsuffix))192 if (load_database(ccollectdir, idxsuffix, txtsuffix)) 187 193 { 188 194 setsearchmode (queryparams); … … 195 201 delete idxsuffix; 196 202 delete txtsuffix; 197 delete c indexhome;203 delete ccollectdir; 198 204 199 205 return databaseloaded; … … 348 354 // defaultindex is needed to load one 349 355 bool mgsearchclass::docTargetDocument(const text_t &defaultindex, 350 const text_t &collection,351 int docnum,352 text_t &output)356 const text_t &collection, 357 int docnum, 358 text_t &output) 353 359 { 354 360 bool databaseloaded = true; … … 423 429 { 424 430 // get the names of the index and text suffixes 425 text_t ttidxsuffix, tttxtsuffix;426 getindexsuffix (defaultindex, collection, ttidxsuffix);427 gettextsuffix (collection, tttxtsuffix);428 char *idxsuffix = ttidxsuffix.getcstr(); assert (idxsuffix != NULL);429 char *txtsuffix = tttxtsuffix.getcstr();assert (txtsuffix != NULL);431 char *idxsuffix = (getindexsuffix (collection, 432 defaultindex)).getcstr(); 433 assert (idxsuffix != NULL); 434 char *txtsuffix = (gettextsuffix (collection)).getcstr(); 435 assert (txtsuffix != NULL); 430 436 431 437 #ifdef __WIN32__ 432 char *c indexhome = (indexhome+"\\").getcstr(); assert (cindexhome!= NULL);438 char *ccollectdir = (collectdir+"\\").getcstr(); assert (ccollectdir != NULL); 433 439 #else 434 char *c indexhome = indexhome.getcstr(); assert (cindexhome!= NULL);440 char *ccollectdir = collectdir.getcstr(); assert (ccollectdir != NULL); 435 441 #endif 436 442 437 438 if (load_database(cindexhome, idxsuffix, txtsuffix)) 439 { 440 databaseloaded = true; 441 } 443 if (load_database(ccollectdir, idxsuffix, txtsuffix)) 444 databaseloaded = true; 442 445 else 443 { 444 databaseloaded = false; 445 } 446 446 databaseloaded = false; 447 447 448 // free up the c strings 448 449 delete idxsuffix; 449 450 delete txtsuffix; 450 delete c indexhome;451 delete ccollectdir; 451 452 } 452 453
Note:
See TracChangeset
for help on using the changeset viewer.