Changeset 138


Ignore:
Timestamp:
1999-02-03T14:13:30+13:00 (25 years ago)
Author:
sjboddie
Message:

Got interface to handle subcollections and language subcollections -
committed changes made to some of the collections

Location:
trunk/gsdl
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/lib/text_t.cpp

    r114 r138  
    1212/*
    1313   $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
    1419   Revision 1.5  1999/01/19 01:38:14  rjmcnab
    1520
     
    364369}
    365370
    366 
     371// return a substring of string from first up to but not including last
     372text_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}
    367381
    368382////////////////////////////////////
  • trunk/gsdl/lib/text_t.h

    r121 r138  
    221221           unsigned short c);
    222222
    223 
    224 
    225 
    226 
     223// return a substring of string from first up to but not including last
     224text_t substr (text_t::const_iterator first, text_t::const_iterator last);
    227225
    228226
  • trunk/gsdl/src/colservr/mgsearch.cpp

    r114 r138  
    1212/*
    1313   $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
    1419   Revision 1.3  1999/01/19 01:38:17  rjmcnab
    1520
     
    7378/////////////////////////
    7479
    75 void getrealdirindex (const text_t &map, text_t &realindex, text_t &dirindex) {
    76   realindex.clear ();
    77   dirindex.clear();
     80void getrealdir (const text_t &map, text_t &realpart, text_t &dirpart) {
     81  realpart.clear ();
     82  dirpart.clear();
    7883
    7984  text_t::const_iterator here = map.begin();
     
    8287  // get the real index
    8388  while (here != end && *here != '-') {
    84     realindex.push_back(*here);
     89    realpart.push_back(*here);
    8590    here++;
    8691  }
     
    9196  // get the dir index
    9297  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
     103void 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
     137void 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
     165void 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
     195bool 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
    99203  text_tarray::const_iterator here = indexmap.begin();
    100204  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
     241text_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
    113249  text_tarray::const_iterator here = indexmap.begin();
    114250  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
     279text_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
    127287  text_tarray::const_iterator here = indexmap.begin();
    128288  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;
    152315}
    153316
     
    186349
    187350text_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  //}
    197360 
    198361  return "";
  • trunk/gsdl/src/colservr/mgsearch.h

    r110 r138  
    2525// appear within the index directory) and real indexes (indexes as they
    2626// appear within the collect.cfg file) and mappings between them.
    27 void getrealdirindex (const text_t &map, text_t &realindex, text_t &dirindex);
     27void 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);
     30void 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);
     33void getrealdir (const text_t &map, text_t &realpart, text_t &dirpart);
     34void getrealdirindex (const text_t &indexmap, const text_t &subcollectionmap,
     35              const text_t &languagemap, text_t &realindex,
     36              text_t &dirindex);
    2837bool 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);
     38bool isrealindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
     39          const text_tarray &languagemap, const text_t &realindex);
     40text_t dir2realindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
     41              const text_tarray &languagemap, const text_t &dirindex);
     42text_t real2dirindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
     43              const text_tarray &languagemap, const text_t &realindex);
    3244text_t real2macroindex (const text_t &realindex);
    3345bool isdoclevelindex (const text_t &realindex);
  • trunk/gsdl/src/library/libinterface.cpp

    r137 r138  
    1212/*
    1313   $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
    1419   Revision 1.17  1999/02/02 10:01:11  rjmcnab
    1520
     
    255260    cfgline.erase(cfgline.begin());
    256261    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;
    258263    else if (key == "defaultindex") cfg_info.defaultindex = cfgline[0];
    259264    else if (key == "macrofiles")   cfg_info.macrofiles = cfgline;
    260265    else if (key == "builddate")    cfg_info.builddate = cfgline[0];
    261266    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;
    262270    else if (key == "numbytes")     cfg_info.numbytes = (double)cfgline[0].getint();
    263271    else if (key == "numdocs")      cfg_info.numdocs = (double)cfgline[0].getint();
     
    318326    default_index.clear();
    319327  } 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)) {
    321330    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);
    323338  } 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);
    325341  }
    326342
     
    328344  // retrieving documents).
    329345  text_default_index = default_index;
    330   if (!isdoclevelindex (cfg_info.defaultindex)) {
    331     text_default_index = real2dirindex (cfg_info.indexmap,
    332                     getdoclevelindex (cfg_info.indexmap));
    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  //}
    334350
    335351  // load up the default macro files, the collection directory
     
    371387
    372388  parse_cgi_args (argstr, args);
     389
    373390  expand_compressed_args (args);
    374391  add_default_args (args);
     
    574591  if (args["p"].empty()) args.setarg("p", cfg_info.defaultpage);
    575592  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
    577634}
    578635
     
    627684  disp.setmacro("g", "Global", args["g"]);
    628685
    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 
    663704
    664705  text_t qtselect;
     
    675716
    676717  disp.setmacro("querytypeselection", "query", qtselect);
     718}
     719
     720void 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);
    677752}
    678753
     
    12161291  caseoption += "\n<input type=radio name=k value=1";
    12171292  if (arg_k) caseoption += " checked";
    1218   caseoption += "> ignore case differences<br>\n";
     1293  caseoption += ">_textignorecase_<br>\n";
    12191294  caseoption += "<input type=radio name=k value=0";
    12201295  if (!arg_k) caseoption += " checked";
    1221   caseoption += "> upper/lower case must match\n";
     1296  caseoption += ">_textmatchcase_\n";
    12221297
    12231298  disp.setmacro ("caseoption", "preferences", caseoption);
     
    12291304  stemoption += "\n<input type=radio name=s value=1";
    12301305  if (arg_s) stemoption += " checked";
    1231   stemoption += "> ignore word endings<br>\n";
     1306  stemoption += ">_textstem_<br>\n";
    12321307  stemoption += "<input type=radio name=s value=0";
    12331308  if (!arg_s) stemoption += " checked";
    1234   stemoption += "> whole word must match\n";
     1309  stemoption += ">_textnostem_\n";
    12351310
    12361311  disp.setmacro ("stemoption", "preferences", stemoption);
  • trunk/gsdl/src/library/libinterface.h

    r137 r138  
    5555
    5656  text_t      maintainer;
    57   text_tarray indexes;
     57//  text_tarray indexes;
    5858  text_t      defaultindex;
    5959  text_tarray macrofiles;
    6060  text_t      builddate;
    6161  text_tarray indexmap;
     62  text_tarray subcollectionmap;
     63  text_tarray languagemap;
    6264  double      numbytes;
    6365  double      numdocs;
     
    156158  virtual void define_general_macros (cgiargsclass &args, outconvertclass &outconvert,
    157159                      ostream &logout);
     160
     161  virtual void set_selection_macro (const text_tarray &map, const text_t &indexarg,
     162                    const text_t &index);
     163
    158164  virtual void prepare_page (cgiargsclass &args, outconvertclass &outconvert,
    159165                 ostream &logout);
Note: See TracChangeset for help on using the changeset viewer.