Changeset 138
- Timestamp:
- 1999-02-03T14:13:30+13:00 (25 years ago)
- Location:
- trunk/gsdl
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/lib/text_t.cpp
r114 r138 12 12 /* 13 13 $Log$ 14 Revision 1.6 1999/02/03 01:13:26 sjboddie 15 16 Got interface to handle subcollections and language subcollections - 17 committed changes made to some of the collections 18 14 19 Revision 1.5 1999/01/19 01:38:14 rjmcnab 15 20 … … 364 369 } 365 370 366 371 // return a substring of string from first up to but not including last 372 text_t substr (text_t::const_iterator first, text_t::const_iterator last) { 373 374 text_t substr; 375 while (first != last) { 376 substr.push_back(*first); 377 first ++; 378 } 379 return substr; 380 } 367 381 368 382 //////////////////////////////////// -
trunk/gsdl/lib/text_t.h
r121 r138 221 221 unsigned short c); 222 222 223 224 225 226 223 // return a substring of string from first up to but not including last 224 text_t substr (text_t::const_iterator first, text_t::const_iterator last); 227 225 228 226 -
trunk/gsdl/src/colservr/mgsearch.cpp
r114 r138 12 12 /* 13 13 $Log$ 14 Revision 1.4 1999/02/03 01:13:27 sjboddie 15 16 Got interface to handle subcollections and language subcollections - 17 committed changes made to some of the collections 18 14 19 Revision 1.3 1999/01/19 01:38:17 rjmcnab 15 20 … … 73 78 ///////////////////////// 74 79 75 void getrealdir index (const text_t &map, text_t &realindex, text_t &dirindex) {76 real index.clear ();77 dir index.clear();80 void getrealdir (const text_t &map, text_t &realpart, text_t &dirpart) { 81 realpart.clear (); 82 dirpart.clear(); 78 83 79 84 text_t::const_iterator here = map.begin(); … … 82 87 // get the real index 83 88 while (here != end && *here != '-') { 84 real index.push_back(*here);89 realpart.push_back(*here); 85 90 here++; 86 91 } … … 91 96 // get the dir index 92 97 while (here != end) { 93 dirindex.push_back(*here); 94 here++; 95 } 96 } 97 98 bool isdirindex (const text_tarray &indexmap, const text_t &dirindex) { 98 dirpart.push_back(*here); 99 here++; 100 } 101 } 102 103 void getrealdirindex (const text_t &indexmap, const text_t &subcollectionmap, 104 const text_t &languagemap, text_t &realindex, 105 text_t &dirindex) { 106 text_t real, dir; 107 realindex.clear(); 108 dirindex.clear(); 109 110 getrealdir (indexmap, real, dir); 111 realindex += real; 112 dirindex += dir; 113 114 getrealdir (subcollectionmap, real, dir); 115 realindex += real; 116 dirindex += dir; 117 118 getrealdir (languagemap, real, dir); 119 realindex += real; 120 dirindex += dir; 121 } 122 123 //bool isdirindex (const text_tarray &indexmap, const text_t &dirindex) { 124 // text_tarray::const_iterator here = indexmap.begin(); 125 // text_tarray::const_iterator end = indexmap.end(); 126 // text_t maprealindex, mapdirindex; 127 128 // while (here != end) { 129 // getrealdirindex (*here, maprealindex, mapdirindex); 130 // if (mapdirindex == dirindex) return true; 131 // here++; 132 // } 133 134 // return false; 135 //} 136 137 void getrealindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap, 138 const text_tarray &languagemap, const text_t &realindex, 139 text_t &index, text_t &subcollection, text_t &language) { 140 141 index.clear(); 142 subcollection.clear(); 143 language.clear(); 144 145 text_tarray parts; 146 splitchar (realindex.begin(), realindex.end(), ':', parts); 147 int numparts = parts.size(); 148 149 if (numparts >= 2) { 150 index = parts[0] + ":" + parts[1]; 151 152 if (numparts == 3) { 153 if (languagemap.empty()) 154 subcollection = parts[2]; 155 else 156 language = parts[2]; 157 } else if (numparts == 4) { 158 subcollection = parts[2]; 159 language = parts[3]; 160 } 161 } 162 } 163 164 165 void getdirindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap, 166 const text_tarray &languagemap, const text_t &dirindex, 167 text_t &index, text_t &subcollection, text_t &language) { 168 169 index.clear(); 170 subcollection.clear(); 171 language.clear(); 172 173 int indexsize = dirindex.size(); 174 if (indexsize != 3 && indexsize != 5 && 175 indexsize != 7) return; 176 177 text_t::const_iterator dibegin = dirindex.begin(); 178 text_t::const_iterator diend = dirindex.end(); 179 180 // first three characters make up index part 181 index = substr(dibegin, dibegin+3); 182 183 if (indexsize == 5) { 184 if (languagemap.empty()) 185 subcollection = substr(dibegin+3, dibegin+5); 186 else 187 language = substr(dibegin+3, dibegin+5); 188 } else if (indexsize == 7) { 189 subcollection = substr(dibegin+3, dibegin+5); 190 language = substr(dibegin+5, diend); 191 } 192 } 193 194 195 bool isrealindex (const text_tarray &indexmap, const text_tarray &subcollectionmap, 196 const text_tarray &languagemap, const text_t &realindex) { 197 198 text_t index, subcollection, language, realpart, dirpart; 199 getrealindexparts (indexmap, subcollectionmap, languagemap, realindex, 200 index, subcollection, language); 201 202 // check index part 99 203 text_tarray::const_iterator here = indexmap.begin(); 100 204 text_tarray::const_iterator end = indexmap.end(); 101 text_t maprealindex, mapdirindex; 102 103 while (here != end) { 104 getrealdirindex (*here, maprealindex, mapdirindex); 105 if (mapdirindex == dirindex) return true; 106 here++; 107 } 108 109 return false; 110 } 111 112 bool isrealindex (const text_tarray &indexmap, const text_t &realindex) { 205 bool exists = false; 206 while (here != end) { 207 getrealdir (*here, realpart, dirpart); 208 if (realpart == index) {exists = true; break;} 209 here++; 210 } 211 if (!exists) return false; 212 213 // check subcollection part if there is one 214 if (!subcollection.empty()) { 215 here = subcollectionmap.begin(); 216 end = subcollectionmap.end(); 217 exists = false; 218 while (here != end) { 219 getrealdir (*here, realpart, dirpart); 220 if (realpart == subcollection) {exists = true; break;} 221 here++; 222 } 223 if (!exists) return false; 224 } 225 226 // check language part if there is one 227 if (!language.empty()) { 228 here = languagemap.begin(); 229 end = languagemap.end(); 230 exists = false; 231 while (here != end) { 232 getrealdir (*here, realpart, dirpart); 233 if (realpart == language) {exists = true; break;} 234 here++; 235 } 236 if (!exists) return false; 237 } 238 return true; 239 } 240 241 text_t dir2realindex (const text_tarray &indexmap, const text_tarray &subcollectionmap, 242 const text_tarray &languagemap, const text_t &dirindex) { 243 244 text_t index, subcollection, language, realpart, dirpart, realindex; 245 getdirindexparts (indexmap, subcollectionmap, languagemap, dirindex, 246 index, subcollection, language); 247 248 // get index part 113 249 text_tarray::const_iterator here = indexmap.begin(); 114 250 text_tarray::const_iterator end = indexmap.end(); 115 text_t maprealindex, mapdirindex; 116 117 while (here != end) { 118 getrealdirindex (*here, maprealindex, mapdirindex); 119 if (maprealindex == realindex) return true; 120 here++; 121 } 122 123 return false; 124 } 125 126 text_t dir2realindex (const text_tarray &indexmap, const text_t &dirindex) { 251 while (here != end) { 252 getrealdir (*here, realpart, dirpart); 253 if (dirpart == index) {realindex += realpart; break;} 254 here++; 255 } 256 257 if (realindex.empty()) return ""; 258 259 // get subcollection part 260 here = subcollectionmap.begin(); 261 end = subcollectionmap.end(); 262 while (here != end) { 263 getrealdir (*here, realpart, dirpart); 264 if (dirpart == subcollection) {realindex += ":" + realpart; break;} 265 here++; 266 } 267 268 // get language part 269 here = languagemap.begin(); 270 end = languagemap.end(); 271 while (here != end) { 272 getrealdir (*here, realpart, dirpart); 273 if (dirpart == language) {realindex += ":" + realpart; break;} 274 here++; 275 } 276 return realindex; 277 } 278 279 text_t real2dirindex (const text_tarray &indexmap, const text_tarray &subcollectionmap, 280 const text_tarray &languagemap, const text_t &realindex) { 281 282 text_t index, subcollection, language, realpart, dirpart, dirindex; 283 getrealindexparts (indexmap, subcollectionmap, languagemap, realindex, 284 index, subcollection, language); 285 286 // get index part 127 287 text_tarray::const_iterator here = indexmap.begin(); 128 288 text_tarray::const_iterator end = indexmap.end(); 129 text_t maprealindex, mapdirindex; 130 131 while (here != end) { 132 getrealdirindex (*here, maprealindex, mapdirindex); 133 if (mapdirindex == dirindex) return maprealindex; 134 here++; 135 } 136 137 return ""; 138 } 139 140 text_t real2dirindex (const text_tarray &indexmap, const text_t &realindex) { 141 text_tarray::const_iterator here = indexmap.begin(); 142 text_tarray::const_iterator end = indexmap.end(); 143 text_t maprealindex, mapdirindex; 144 145 while (here != end) { 146 getrealdirindex (*here, maprealindex, mapdirindex); 147 if (maprealindex == realindex) return mapdirindex; 148 here++; 149 } 150 151 return ""; 289 while (here != end) { 290 getrealdir (*here, realpart, dirpart); 291 if (realpart == index) {dirindex += dirpart; break;} 292 here++; 293 } 294 295 if (dirindex.empty()) return ""; 296 297 // get subcollection part 298 here = subcollectionmap.begin(); 299 end = subcollectionmap.end(); 300 while (here != end) { 301 getrealdir (*here, realpart, dirpart); 302 if (realpart == subcollection) {dirindex += dirpart; break;} 303 here++; 304 } 305 306 // get language part 307 here = languagemap.begin(); 308 end = languagemap.end(); 309 while (here != end) { 310 getrealdir (*here, realpart, dirpart); 311 if (realpart == language) {dirindex += dirpart; break;} 312 here++; 313 } 314 return dirindex; 152 315 } 153 316 … … 186 349 187 350 text_t getdoclevelindex (const text_tarray &indexmap) { 188 text_tarray::const_iterator here = indexmap.begin();189 text_tarray::const_iterator end = indexmap.end();190 text_t maprealindex, mapdirindex;191 192 while (here != end) {193 getrealdirindex (*here, maprealindex, mapdirindex);194 if (isdoclevelindex (maprealindex)) return maprealindex;195 here++;196 }351 //text_tarray::const_iterator here = indexmap.begin(); 352 //text_tarray::const_iterator end = indexmap.end(); 353 //text_t maprealindex, mapdirindex; 354 355 // while (here != end) { 356 // getrealdirindex (*here, maprealindex, mapdirindex); 357 // if (isdoclevelindex (maprealindex)) return maprealindex; 358 // here++; 359 //} 197 360 198 361 return ""; -
trunk/gsdl/src/colservr/mgsearch.h
r110 r138 25 25 // appear within the index directory) and real indexes (indexes as they 26 26 // appear within the collect.cfg file) and mappings between them. 27 void getrealdirindex (const text_t &map, text_t &realindex, text_t &dirindex); 27 void getdirindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap, 28 const text_tarray &languagemap, const text_t &dirindex, 29 text_t &index, text_t &subcollection, text_t &language); 30 void getrealindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap, 31 const text_tarray &languagemap, const text_t &realindex, 32 text_t &index, text_t &subcollection, text_t &language); 33 void getrealdir (const text_t &map, text_t &realpart, text_t &dirpart); 34 void getrealdirindex (const text_t &indexmap, const text_t &subcollectionmap, 35 const text_t &languagemap, text_t &realindex, 36 text_t &dirindex); 28 37 bool isdirindex (const text_tarray &indexmap, const text_t &dirindex); 29 bool isrealindex (const text_tarray &indexmap, const text_t &realindex); 30 text_t dir2realindex (const text_tarray &indexmap, const text_t &dirindex); 31 text_t real2dirindex (const text_tarray &indexmap, const text_t &realindex); 38 bool isrealindex (const text_tarray &indexmap, const text_tarray &subcollectionmap, 39 const text_tarray &languagemap, const text_t &realindex); 40 text_t dir2realindex (const text_tarray &indexmap, const text_tarray &subcollectionmap, 41 const text_tarray &languagemap, const text_t &dirindex); 42 text_t real2dirindex (const text_tarray &indexmap, const text_tarray &subcollectionmap, 43 const text_tarray &languagemap, const text_t &realindex); 32 44 text_t real2macroindex (const text_t &realindex); 33 45 bool isdoclevelindex (const text_t &realindex); -
trunk/gsdl/src/library/libinterface.cpp
r137 r138 12 12 /* 13 13 $Log$ 14 Revision 1.18 1999/02/03 01:13:29 sjboddie 15 16 Got interface to handle subcollections and language subcollections - 17 committed changes made to some of the collections 18 14 19 Revision 1.17 1999/02/02 10:01:11 rjmcnab 15 20 … … 255 260 cfgline.erase(cfgline.begin()); 256 261 if (key == "maintainer") cfg_info.maintainer = cfgline[0]; 257 else if (key == "indexes") cfg_info.indexes = cfgline;262 // else if (key == "indexes") cfg_info.indexes = cfgline; 258 263 else if (key == "defaultindex") cfg_info.defaultindex = cfgline[0]; 259 264 else if (key == "macrofiles") cfg_info.macrofiles = cfgline; 260 265 else if (key == "builddate") cfg_info.builddate = cfgline[0]; 261 266 else if (key == "indexmap") cfg_info.indexmap = cfgline; 267 else if (key == "subcollectionmap") 268 cfg_info.subcollectionmap = cfgline; 269 else if (key == "languagemap") cfg_info.languagemap = cfgline; 262 270 else if (key == "numbytes") cfg_info.numbytes = (double)cfgline[0].getint(); 263 271 else if (key == "numdocs") cfg_info.numdocs = (double)cfgline[0].getint(); … … 318 326 default_index.clear(); 319 327 } else if (cfg_info.defaultindex.empty() || 320 !isrealindex (cfg_info.indexmap, cfg_info.defaultindex)) { 328 !isrealindex (cfg_info.indexmap, cfg_info.subcollectionmap, 329 cfg_info.languagemap, cfg_info.defaultindex)) { 321 330 logout << "warning: the default index has been reset to the first index\n"; 322 getrealdirindex (cfg_info.indexmap[0], cfg_info.defaultindex, default_index); 331 text_t subcollection, language; 332 if (!cfg_info.subcollectionmap.empty()) 333 subcollection = cfg_info.subcollectionmap[0]; 334 if (!cfg_info.languagemap.empty()) 335 language = cfg_info.languagemap[0]; 336 getrealdirindex (cfg_info.indexmap[0], subcollection, 337 language, cfg_info.defaultindex, default_index); 323 338 } else { 324 default_index = real2dirindex (cfg_info.indexmap, cfg_info.defaultindex); 339 default_index = real2dirindex (cfg_info.indexmap, cfg_info.subcollectionmap, 340 cfg_info.languagemap, cfg_info.defaultindex); 325 341 } 326 342 … … 328 344 // retrieving documents). 329 345 text_default_index = default_index; 330 if (!isdoclevelindex (cfg_info.defaultindex)) {331 text_default_index = real2dirindex (cfg_info.indexmap,332 333 }346 //if (!isdoclevelindex (cfg_info.defaultindex)) { 347 // text_default_index = real2dirindex (cfg_info.indexmap, cfg_info.subcollectionmap, 348 // cfg_info.languagemap, getdoclevelindex (cfg_info.indexmap)); 349 //} 334 350 335 351 // load up the default macro files, the collection directory … … 371 387 372 388 parse_cgi_args (argstr, args); 389 373 390 expand_compressed_args (args); 374 391 add_default_args (args); … … 574 591 if (args["p"].empty()) args.setarg("p", cfg_info.defaultpage); 575 592 if (args["w"].empty()) args.setarg("w", cfg_info.defaultencoding); 576 if (args["i"].empty()) args.setarg("i", default_index); 593 594 // override those parts of the index that need it 595 int indexsize = args["i"].size(); 596 if ((indexsize < 3) || (indexsize > 7)) { 597 args["i"] = args["h"] + args["i"] + args["n"]; 598 } else { 599 if (args["h"].size() == 3) { 600 args["i"][0] = args["h"][0]; 601 args["i"][1] = args["h"][1]; 602 args["i"][2] = args["h"][2]; 603 } 604 605 if (args["j"].size() == 2) { 606 if (indexsize >= 5) { 607 args["i"][3] = args["j"][0]; 608 args["i"][4] = args["j"][1]; 609 } else { 610 args["i"] += args["j"]; 611 } 612 } 613 if (args["n"].size() == 2) { 614 if (cfg_info.subcollectionmap.empty()) { 615 if (args["i"].size() >= 5) { 616 args["i"][3] = args["n"][0]; 617 args["i"][4] = args["n"][1]; 618 } else { 619 args["i"] += args["n"]; 620 } 621 } else { 622 if (args["i"].size() == 7) { 623 args["i"][5] = args["n"][0]; 624 args["i"][6] = args["n"][1]; 625 } else { 626 args["i"] += args["n"]; 627 } 628 } 629 } 630 } 631 if ((args["i"].size() < 3) || (args["i"].size() > 7)) 632 args.setarg("i", default_index); 633 577 634 } 578 635 … … 627 684 disp.setmacro("g", "Global", args["g"]); 628 685 629 // set the selection macros 630 631 text_t indexselect; 632 text_t maprealindex, mapdirindex; 633 if (cfg_info.indexmap.size() == 1) { 634 getrealdirindex (cfg_info.indexmap[0], maprealindex, mapdirindex); 635 indexselect += "<input type=hidden name=\"i\" value=\""; 636 indexselect += mapdirindex; 637 indexselect += "\">_query:"; 638 indexselect += real2macroindex (maprealindex); 639 indexselect += "_\n"; 640 641 } else { 642 text_t &arg_i = args["i"]; 643 text_tarray::const_iterator maphere = cfg_info.indexmap.begin(); 644 text_tarray::const_iterator mapend = cfg_info.indexmap.end(); 645 646 indexselect += "<select name=\"i\">\n"; 647 while (maphere != mapend) { 648 getrealdirindex (*maphere, maprealindex, mapdirindex); 649 indexselect += "<option value=\""; 650 indexselect += mapdirindex; 651 indexselect += "\""; 652 if (arg_i == mapdirindex) indexselect += " selected"; 653 indexselect += ">_query:"; 654 indexselect += real2macroindex (maprealindex); 655 indexselect += "_\n"; 656 657 maphere++; 658 } 659 indexselect += "</select>\n"; 660 } 661 662 disp.setmacro("indexselection", "query", indexselect); 686 // set the selection macros 687 688 text_t index, subcollection, language; 689 getdirindexparts (cfg_info.indexmap, cfg_info.subcollectionmap, 690 cfg_info.languagemap, args["i"], index, 691 subcollection, language); 692 693 // main part of index 694 set_selection_macro (cfg_info.indexmap, index, "h"); 695 696 // subcollection part of index 697 if (!cfg_info.subcollectionmap.empty()) 698 set_selection_macro (cfg_info.subcollectionmap, subcollection, "j"); 699 700 // language part of index 701 if (!cfg_info.languagemap.empty()) 702 set_selection_macro (cfg_info.languagemap, language, "n"); 703 663 704 664 705 text_t qtselect; … … 675 716 676 717 disp.setmacro("querytypeselection", "query", qtselect); 718 } 719 720 void libinterface::set_selection_macro (const text_tarray &map, const text_t &indexarg, 721 const text_t &index) { 722 723 text_t maprealindex, mapdirindex, indexselect; 724 725 if (map.size() == 1) { 726 getrealdir (map[0], maprealindex, mapdirindex); 727 indexselect += "<input type=hidden name=\"" + index + "\" value=\""; 728 indexselect += mapdirindex + "\">_query:"; 729 indexselect += real2macroindex (maprealindex); 730 indexselect += "_\n"; 731 732 } else { 733 text_tarray::const_iterator maphere = map.begin(); 734 text_tarray::const_iterator mapend = map.end(); 735 736 indexselect += "<select name=\"" + index +"\">\n"; 737 while (maphere != mapend) { 738 getrealdir (*maphere, maprealindex, mapdirindex); 739 indexselect += "<option value=\""; 740 indexselect += mapdirindex; 741 indexselect += "\""; 742 if (indexarg == mapdirindex) indexselect += " selected"; 743 indexselect += ">_query:"; 744 indexselect += real2macroindex (maprealindex); 745 indexselect += "_\n"; 746 747 maphere++; 748 } 749 indexselect += "</select>\n"; 750 } 751 disp.setmacro(index + "selection", "query", indexselect); 677 752 } 678 753 … … 1216 1291 caseoption += "\n<input type=radio name=k value=1"; 1217 1292 if (arg_k) caseoption += " checked"; 1218 caseoption += "> ignore case differences<br>\n";1293 caseoption += ">_textignorecase_<br>\n"; 1219 1294 caseoption += "<input type=radio name=k value=0"; 1220 1295 if (!arg_k) caseoption += " checked"; 1221 caseoption += "> upper/lower case must match\n";1296 caseoption += ">_textmatchcase_\n"; 1222 1297 1223 1298 disp.setmacro ("caseoption", "preferences", caseoption); … … 1229 1304 stemoption += "\n<input type=radio name=s value=1"; 1230 1305 if (arg_s) stemoption += " checked"; 1231 stemoption += "> ignore word endings<br>\n";1306 stemoption += ">_textstem_<br>\n"; 1232 1307 stemoption += "<input type=radio name=s value=0"; 1233 1308 if (!arg_s) stemoption += " checked"; 1234 stemoption += "> whole word must match\n";1309 stemoption += ">_textnostem_\n"; 1235 1310 1236 1311 disp.setmacro ("stemoption", "preferences", stemoption); -
trunk/gsdl/src/library/libinterface.h
r137 r138 55 55 56 56 text_t maintainer; 57 text_tarray indexes;57 // text_tarray indexes; 58 58 text_t defaultindex; 59 59 text_tarray macrofiles; 60 60 text_t builddate; 61 61 text_tarray indexmap; 62 text_tarray subcollectionmap; 63 text_tarray languagemap; 62 64 double numbytes; 63 65 double numdocs; … … 156 158 virtual void define_general_macros (cgiargsclass &args, outconvertclass &outconvert, 157 159 ostream &logout); 160 161 virtual void set_selection_macro (const text_tarray &map, const text_t &indexarg, 162 const text_t &index); 163 158 164 virtual void prepare_page (cgiargsclass &args, outconvertclass &outconvert, 159 165 ostream &logout);
Note:
See TracChangeset
for help on using the changeset viewer.