Changeset 1373


Ignore:
Timestamp:
2000-08-08T15:46:13+12:00 (24 years ago)
Author:
dmm9
Message:

Support for date search

Location:
trunk/gsdl/src/recpt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/queryaction.cpp

    r1347 r1373  
    276276  argsinfo.addarginfo (NULL, arg_ainfo);
    277277
    278 
     278     // "ds" - start date
     279  arg_ainfo.shortname = "ds";
     280  arg_ainfo.longname = "start date";
     281  arg_ainfo.multiplechar = true;
     282  arg_ainfo.defaultstatus = cgiarginfo::weak;
     283  arg_ainfo.argdefault = "";
     284  arg_ainfo.savedarginfo = cgiarginfo::must;
     285  argsinfo.addarginfo (NULL, arg_ainfo);
     286
     287  // "de" - end date
     288  arg_ainfo.shortname = "de";
     289  arg_ainfo.longname = "end date";
     290  arg_ainfo.multiplechar = true;
     291  arg_ainfo.defaultstatus = cgiarginfo::weak;
     292  arg_ainfo.argdefault = "";
     293  arg_ainfo.savedarginfo = cgiarginfo::must;
     294  argsinfo.addarginfo (NULL, arg_ainfo);
     295
     296  // "dsbc" - whether or not start date is prechristian
     297  arg_ainfo.shortname = "dsbc";
     298  arg_ainfo.longname = "start date bc";
     299  arg_ainfo.multiplechar = false;
     300  arg_ainfo.defaultstatus = cgiarginfo::weak;
     301  arg_ainfo.argdefault = "0";
     302  arg_ainfo.savedarginfo = cgiarginfo::must;
     303  argsinfo.addarginfo (NULL, arg_ainfo);
     304
     305  // "debc" - whether or not end date is prechristian
     306  arg_ainfo.shortname = "debc";
     307  arg_ainfo.longname = "end date bc";
     308  arg_ainfo.multiplechar = false;
     309  arg_ainfo.defaultstatus = cgiarginfo::weak;
     310  arg_ainfo.argdefault = "0";
     311  arg_ainfo.savedarginfo = cgiarginfo::must;
     312  argsinfo.addarginfo (NULL, arg_ainfo);
    279313
    280314}
     
    9981032
    9991033  format_querystring (formattedstring, args.getintarg("b"));
     1034  //add_ands(formattedstring, args.getintarg("t"));
     1035  add_dates(formattedstring, args.getintarg("ds"), args.getintarg("de"),
     1036        args.getintarg("dsbc"), args.getintarg("debc"));
    10001037  set_queryfilter_options (request, formattedstring, args);
    10011038  collectproto->filter (collection, request, response, err, logout);
     
    10451082  TermInfo_tarray::const_iterator end_term = response.termInfo.end();
    10461083  while (this_term != end_term) {
    1047     freqmsg += (*this_term).term + ": " + (*this_term).freq;
    1048     if ((this_term + 1) != end_term)
    1049       freqmsg += ", ";
     1084    char *term = (*this_term).term.getcstr();
     1085    if(term[0]<'0' || term[0] >'9'){
     1086      freqmsg += (*this_term).term + ": " + (*this_term).freq;
     1087      if ((this_term + 1) != end_term)
     1088    freqmsg += ", ";
     1089    }
     1090    delete term;
    10501091    this_term ++;
    10511092  }
     
    11341175
    11351176}
     1177
     1178
     1179
     1180
     1181
     1182
  • trunk/gsdl/src/recpt/querytools.cpp

    r1329 r1373  
    2525
    2626#include "querytools.h"
    27 
     27#include <ctype.h>
    2828
    2929// request.filterResultOptions and request.fields (if required) should
     
    185185}
    186186
     187void add_ands(text_t& querystring, int querytype)
     188{
     189
     190  if(querytype==0)
     191    {
     192      text_t formattedstring;
     193     
     194      bool spacelast = false;
     195     
     196      text_t::const_iterator here = querystring.begin();
     197      text_t::const_iterator end = querystring.end();
     198     
     199
     200      querystring = formattedstring;
     201
     202      while(here!=end && isspace((*here)))
     203    here++;
     204     
     205      if(here==end)
     206    return;
     207
     208      while(here!=end)
     209    {
     210      if(isspace((*here)))
     211      {
     212        while(here!=end && isspace((*here)))
     213          here++;
     214        if(here!=end)
     215          formattedstring.appendcstr(" AND ");
     216      }
     217      if(!isspace((*here)))
     218        {
     219          formattedstring.push_back((*here));
     220        }
     221      here++;
     222    }
     223      querystring = formattedstring;
     224    }
     225}
     226
     227 
     228   
     229void add_dates(text_t &querystring, int startdate, int enddate,
     230           int startbc, int endbc)
     231{
     232  if(startdate)
     233    {
     234      int querystringis = 0;
     235      text_t::const_iterator here = querystring.begin();
     236      text_t::const_iterator end = querystring.end();
     237      while(here!=end)
     238    {
     239      if(!(isspace((*here)))){
     240        here = end;
     241        querystringis = 1;
     242      }
     243      else
     244        here++;
     245    }
     246      //converting BCE dates
     247      if(startbc && startdate > 0)
     248    {
     249      startdate *= -1;
     250    }
     251      if(endbc && enddate > 0)
     252    {
     253      enddate *= -1;
     254    }
     255       if(enddate != 0 && enddate<startdate)
     256    {
     257      cout<<"enddate too small"<<endl;
     258      return;
     259    }
     260       if(querystringis)
     261     querystring.appendcstr(" AND");
     262       if(!enddate)
     263     {
     264       querystring.appendcstr(" [");
     265       querystring.appendint(startdate);
     266       querystring.appendcstr("]:Date");
     267     }
     268       else{
     269     int nextdate = startdate;
     270     querystring.appendcstr(" (");
     271     while(nextdate<=enddate)
     272       {
     273         if(nextdate!=0)
     274           {
     275          querystring.appendcstr(" [");
     276          querystring.appendint(nextdate);
     277          querystring.appendcstr("]:Date");
     278           }
     279         nextdate++;
     280       }
     281     querystring.appendcstr(" )");
     282       }
     283    }
     284}
    187285void get_phrases (const text_t &querystring, text_tarray &phrases) {
    188286
  • trunk/gsdl/src/recpt/querytools.h

    r1285 r1373  
    4242void format_querystring (text_t &querystring, int querymode);
    4343
     44void add_dates(text_t &querystring, int startdate, int enddate,
     45           int startbc, int endbc);
     46
    4447void get_phrases (const text_t &querystring, text_tarray &phrases);
    4548
     49void add_ands(text_t& querystring, int querytype);
     50
    4651#endif
     52
     53
     54
     55
Note: See TracChangeset for help on using the changeset viewer.