Ignore:
Timestamp:
1998-12-30T16:50:37+13:00 (25 years ago)
Author:
rjmcnab
Message:

Changed the directory structure (collect.cfg and site.cfg now reside
in the collection/etc directory). Changed all input to the library
software to be converted from utf-8 to unicode (info database, mg,
and display). Got lib.init to read in collect.cfg and build.cfg and
used the information to read in the macrofiles. Made it check for each
macro file in both the collection directory and then the main directory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/library/mgsearch.cpp

    r32 r91  
    2727#include "mgsearch.h"
    2828#include "locateinfo.h"
     29#include "gsdlunicode.h"
     30#include "unitool.h"
     31
    2932
    3033/////////////
     
    8285          float Weight, void *info) {
    8386
     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
    8495  queryresultsclass *queryresults = (queryresultsclass *)info;
    85   queryresults->termvariants.push_back(Word);
     96  queryresults->termvariants.push_back(term);
    8697
    8798  return 0;
     
    93104  text_t *output = (text_t *)info;
    94105  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);
    97113 
    98114  // replace all control-Cs with spaces
    99115  text_t::iterator here = output->begin();
    100116  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  }
    106121 
    107122  return 0;
     
    129144
    130145
    131 void mgsearchclass::setindexhome (const text_t &theindexhome)
    132 {
    133   indexhome = theindexhome;
     146void mgsearchclass::setcollectdir (const text_t &thecollectdir)
     147{
     148  collectdir = thecollectdir;
    134149}
    135150
    136151
    137152bool mgsearchclass::search(const queryparamclass &queryparams,
    138               queryresultsclass &queryresults)
     153               queryresultsclass &queryresults)
    139154{
    140155  bool databaseloaded = true;
     
    146161  // first check the cache
    147162  if (cache->find(queryparams, queryresults))
    148     {
    149       return true;
    150     }
     163    return true;
    151164
    152165  // make sure there is a query to be processed
     
    154167  text_t::const_iterator queryend = queryparams.querystring.end();
    155168  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;
    162170    queryhere++;
    163171  }
     
    169177
    170178
    171 
    172179  // 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);
    179185
    180186#ifdef __WIN32__
    181   char *cindexhome = (indexhome+"\\").getcstr(); assert (cindexhome != NULL);
     187  char *ccollectdir = (collectdir+"\\").getcstr(); assert (ccollectdir != NULL);
    182188#else
    183   char *cindexhome = indexhome.getcstr(); assert (cindexhome != NULL);
     189  char *ccollectdir = collectdir.getcstr(); assert (ccollectdir != NULL);
    184190#endif
    185191
    186   if (load_database(cindexhome, idxsuffix, txtsuffix))
     192  if (load_database(ccollectdir, idxsuffix, txtsuffix))
    187193    {
    188194      setsearchmode (queryparams);
     
    195201  delete idxsuffix;
    196202  delete txtsuffix;
    197   delete cindexhome;
     203  delete ccollectdir;
    198204
    199205  return databaseloaded;
     
    348354// defaultindex is needed to load one
    349355bool 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)
    353359{
    354360  bool databaseloaded = true;
     
    423429    {
    424430      // 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);
    430436
    431437#ifdef __WIN32__
    432       char *cindexhome = (indexhome+"\\").getcstr(); assert (cindexhome != NULL);
     438      char *ccollectdir = (collectdir+"\\").getcstr(); assert (ccollectdir != NULL);
    433439#else
    434       char *cindexhome = indexhome.getcstr(); assert (cindexhome != NULL);
     440      char *ccollectdir = collectdir.getcstr(); assert (ccollectdir != NULL);
    435441#endif
    436442     
    437 
    438       if (load_database(cindexhome, idxsuffix, txtsuffix))
    439     {
    440       databaseloaded = true;
    441     }
     443      if (load_database(ccollectdir, idxsuffix, txtsuffix))
     444    databaseloaded = true;
    442445      else
    443     {
    444       databaseloaded = false;
    445     }
    446      
     446    databaseloaded = false;
     447     
    447448      // free up the c strings
    448449      delete idxsuffix;
    449450      delete txtsuffix;
    450       delete cindexhome;
     451      delete ccollectdir;
    451452    }
    452453 
Note: See TracChangeset for help on using the changeset viewer.