Changeset 301
- Timestamp:
- 1999-06-28T10:07:27+12:00 (25 years ago)
- Location:
- trunk/gsdl/src/colservr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/colservr/mgsearch.cpp
r265 r301 12 12 /* 13 13 $Log$ 14 Revision 1.7 1999/06/27 22:07:27 sjboddie 15 got rid of all the old functions for dealing with dir indexes 16 14 17 Revision 1.6 1999/06/09 00:41:32 sjboddie 15 18 phrase searching now uses case-folding if it's turned on … … 81 84 static char *quotedquery = NULL; 82 85 static int casefold; 83 84 85 /////////////////////////86 // index map functions //87 /////////////////////////88 89 void getrealdir (const text_t &map, text_t &realpart, text_t &dirpart) {90 realpart.clear ();91 dirpart.clear();92 93 text_t::const_iterator here = map.begin();94 text_t::const_iterator end = map.end();95 96 // get the real index97 while (here != end && *here != '-') {98 realpart.push_back(*here);99 here++;100 }101 102 if (here != end) here++;103 if (here != end && *here == '>') here++;104 105 // get the dir index106 while (here != end) {107 dirpart.push_back(*here);108 here++;109 }110 }111 112 void getrealdirindex (const text_t &indexmap, const text_t &subcollectionmap,113 const text_t &languagemap, text_t &realindex,114 text_t &dirindex) {115 text_t real, dir;116 realindex.clear();117 dirindex.clear();118 119 getrealdir (indexmap, real, dir);120 realindex += real;121 dirindex += dir;122 123 getrealdir (subcollectionmap, real, dir);124 realindex += real;125 dirindex += dir;126 127 getrealdir (languagemap, real, dir);128 realindex += real;129 dirindex += dir;130 }131 132 //bool isdirindex (const text_tarray &indexmap, const text_t &dirindex) {133 // text_tarray::const_iterator here = indexmap.begin();134 // text_tarray::const_iterator end = indexmap.end();135 // text_t maprealindex, mapdirindex;136 137 // while (here != end) {138 // getrealdirindex (*here, maprealindex, mapdirindex);139 // if (mapdirindex == dirindex) return true;140 // here++;141 // }142 143 // return false;144 //}145 146 void getrealindexparts (const text_tarray &/*indexmap*/, const text_tarray &/*subcollectionmap*/,147 const text_tarray &languagemap, const text_t &realindex,148 text_t &index, text_t &subcollection, text_t &language) {149 150 index.clear();151 subcollection.clear();152 language.clear();153 154 text_tarray parts;155 splitchar (realindex.begin(), realindex.end(), ':', parts);156 int numparts = parts.size();157 158 if (numparts >= 2) {159 index = parts[0] + ":" + parts[1];160 161 if (numparts == 3) {162 if (languagemap.empty())163 subcollection = parts[2];164 else165 language = parts[2];166 } else if (numparts == 4) {167 subcollection = parts[2];168 language = parts[3];169 }170 }171 }172 173 174 void getdirindexparts (const text_tarray &/*indexmap*/, const text_tarray &/*subcollectionmap*/,175 const text_tarray &languagemap, const text_t &dirindex,176 text_t &index, text_t &subcollection, text_t &language) {177 178 index.clear();179 subcollection.clear();180 language.clear();181 182 int indexsize = dirindex.size();183 if (indexsize != 3 && indexsize != 5 &&184 indexsize != 7) return;185 186 text_t::const_iterator dibegin = dirindex.begin();187 text_t::const_iterator diend = dirindex.end();188 189 // first three characters make up index part190 index = substr(dibegin, dibegin+3);191 192 if (indexsize == 5) {193 if (languagemap.empty())194 subcollection = substr(dibegin+3, dibegin+5);195 else196 language = substr(dibegin+3, dibegin+5);197 } else if (indexsize == 7) {198 subcollection = substr(dibegin+3, dibegin+5);199 language = substr(dibegin+5, diend);200 }201 }202 203 204 bool isrealindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,205 const text_tarray &languagemap, const text_t &realindex) {206 207 text_t index, subcollection, language, realpart, dirpart;208 getrealindexparts (indexmap, subcollectionmap, languagemap, realindex,209 index, subcollection, language);210 211 // check index part212 text_tarray::const_iterator here = indexmap.begin();213 text_tarray::const_iterator end = indexmap.end();214 bool exists = false;215 while (here != end) {216 getrealdir (*here, realpart, dirpart);217 if (realpart == index) {exists = true; break;}218 here++;219 }220 if (!exists) return false;221 222 // check subcollection part if there is one223 if (!subcollection.empty()) {224 here = subcollectionmap.begin();225 end = subcollectionmap.end();226 exists = false;227 while (here != end) {228 getrealdir (*here, realpart, dirpart);229 if (realpart == subcollection) {exists = true; break;}230 here++;231 }232 if (!exists) return false;233 }234 235 // check language part if there is one236 if (!language.empty()) {237 here = languagemap.begin();238 end = languagemap.end();239 exists = false;240 while (here != end) {241 getrealdir (*here, realpart, dirpart);242 if (realpart == language) {exists = true; break;}243 here++;244 }245 if (!exists) return false;246 }247 return true;248 }249 250 text_t dir2realindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,251 const text_tarray &languagemap, const text_t &dirindex) {252 253 text_t index, subcollection, language, realpart, dirpart, realindex;254 getdirindexparts (indexmap, subcollectionmap, languagemap, dirindex,255 index, subcollection, language);256 257 // get index part258 text_tarray::const_iterator here = indexmap.begin();259 text_tarray::const_iterator end = indexmap.end();260 while (here != end) {261 getrealdir (*here, realpart, dirpart);262 if (dirpart == index) {realindex += realpart; break;}263 here++;264 }265 266 if (realindex.empty()) return "";267 268 // get subcollection part269 here = subcollectionmap.begin();270 end = subcollectionmap.end();271 while (here != end) {272 getrealdir (*here, realpart, dirpart);273 if (dirpart == subcollection) {realindex += ":" + realpart; break;}274 here++;275 }276 277 // get language part278 here = languagemap.begin();279 end = languagemap.end();280 while (here != end) {281 getrealdir (*here, realpart, dirpart);282 if (dirpart == language) {realindex += ":" + realpart; break;}283 here++;284 }285 return realindex;286 }287 288 text_t real2dirindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,289 const text_tarray &languagemap, const text_t &realindex) {290 291 text_t index, subcollection, language, realpart, dirpart, dirindex;292 getrealindexparts (indexmap, subcollectionmap, languagemap, realindex,293 index, subcollection, language);294 295 // get index part296 text_tarray::const_iterator here = indexmap.begin();297 text_tarray::const_iterator end = indexmap.end();298 while (here != end) {299 getrealdir (*here, realpart, dirpart);300 if (realpart == index) {dirindex += dirpart; break;}301 here++;302 }303 304 if (dirindex.empty()) return "";305 306 // get subcollection part307 here = subcollectionmap.begin();308 end = subcollectionmap.end();309 while (here != end) {310 getrealdir (*here, realpart, dirpart);311 if (realpart == subcollection) {dirindex += dirpart; break;}312 here++;313 }314 315 // get language part316 here = languagemap.begin();317 end = languagemap.end();318 while (here != end) {319 getrealdir (*here, realpart, dirpart);320 if (realpart == language) {dirindex += dirpart; break;}321 here++;322 }323 return dirindex;324 }325 326 text_t real2macroindex (const text_t &realindex) {327 text_t macroindex;328 text_t::const_iterator here = realindex.begin();329 text_t::const_iterator end = realindex.end();330 unsigned short c;331 332 while (here != end) {333 c = *here;334 if ((c >= '0' && c <= '9') ||335 (c >= 'A' && c <= 'Z') ||336 (c >= 'a' && c <= 'z'))337 macroindex.push_back (*here);338 here++;339 }340 341 return macroindex;342 }343 344 bool isdoclevelindex (const text_t &realindex) {345 char *docstr = "document";346 text_t::const_iterator here = realindex.begin ();347 text_t::const_iterator end = realindex.end ();348 349 while (here != end) {350 if (*docstr == '\0') return true;351 if (*docstr != (char)(*here)) return false;352 docstr++;353 here++;354 }355 356 return false;357 }358 359 text_t getdoclevelindex (const text_tarray &/*indexmap*/) {360 //text_tarray::const_iterator here = indexmap.begin();361 //text_tarray::const_iterator end = indexmap.end();362 //text_t maprealindex, mapdirindex;363 364 // while (here != end) {365 // getrealdirindex (*here, maprealindex, mapdirindex);366 // if (isdoclevelindex (maprealindex)) return maprealindex;367 // here++;368 //}369 370 return "";371 }372 373 374 86 375 87 -
trunk/gsdl/src/colservr/mgsearch.h
r226 r301 21 21 #define MAXNUMDOCS 500 22 22 #define MAXNUMTERMS 100 23 24 // a few useful functions for dealing with dir indexes (indexes as they25 // appear within the index directory) and real indexes (indexes as they26 // appear within the collect.cfg file) and mappings between them.27 28 // all these functions can go when we don't need src/library any more29 30 void getdirindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap,31 const text_tarray &languagemap, const text_t &dirindex,32 text_t &index, text_t &subcollection, text_t &language);33 void getrealindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap,34 const text_tarray &languagemap, const text_t &realindex,35 text_t &index, text_t &subcollection, text_t &language);36 void getrealdir (const text_t &map, text_t &realpart, text_t &dirpart);37 void getrealdirindex (const text_t &indexmap, const text_t &subcollectionmap,38 const text_t &languagemap, text_t &realindex,39 text_t &dirindex);40 bool isdirindex (const text_tarray &indexmap, const text_t &dirindex);41 bool isrealindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,42 const text_tarray &languagemap, const text_t &realindex);43 text_t dir2realindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,44 const text_tarray &languagemap, const text_t &dirindex);45 text_t real2dirindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,46 const text_tarray &languagemap, const text_t &realindex);47 text_t real2macroindex (const text_t &realindex);48 bool isdoclevelindex (const text_t &realindex);49 text_t getdoclevelindex (const text_tarray &indexmap);50 51 52 23 53 24 class mgsearchclass {
Note:
See TracChangeset
for help on using the changeset viewer.