Changeset 397 for trunk/gsdl/src/recpt


Ignore:
Timestamp:
1999-07-16T12:19:02+12:00 (25 years ago)
Author:
sjboddie
Message:

some changes to the way quoted queries are handled

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

Legend:

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

    r346 r397  
    1212/*
    1313   $Log$
     14   Revision 1.12  1999/07/16 00:19:01  sjboddie
     15   some changes to the way quoted queries are handled
     16
    1417   Revision 1.11  1999/07/07 05:47:41  sjboddie
    1518   changed around the way browsetools works
     
    638641    FilterRequest_t request;
    639642    request.filterResultOptions = FRmatchTerms;
    640     text_t quotedquery; // not used
    641     if (do_query (request, args, collectproto, quotedquery, queryresponse, logout))
     643    if (do_query (request, args, collectproto, queryresponse, logout))
    642644      highlight = true;
    643645  }
  • trunk/gsdl/src/recpt/queryaction.cpp

    r356 r397  
    1212/*
    1313   $Log$
     14   Revision 1.13  1999/07/16 00:19:01  sjboddie
     15   some changes to the way quoted queries are handled
     16
    1417   Revision 1.12  1999/07/09 02:17:55  rjmcnab
    1518   Setting macros needed for a second query.
     
    282285}
    283286
    284 void queryaction::define_internal_macros (displayclass &/*disp*/, cgiargsclass &/*args*/,
     287void queryaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
    285288                      recptproto */*collectproto*/, ostream &/*logout*/) {
    286289
    287   // define_internal_macros doesn't set anything for this action. The following
    288   // macros are set later though in define_query_macros (they can't be set until
    289   // the query has been done).
     290  // define_internal_macros doesn't sets the following macros.
     291
     292  // _quotedquery_  the part of the query string that was quoted for post-processing
     293
     294
     295
     296  // The following macros are set later (in define_query_macros) as they can't be set until
     297  // the query has been done.
    290298
    291299  // _freqmsg_      the term frequency string
    292 
    293   // _quotedquery_  the part of the query string that was quoted for post-processing
    294300
    295301  // _resultline_   the "x documents matched the query" string
     
    301307  // _thisfirst_
    302308  // _thislast_
    303  
     309
     310
     311
     312  // get the quoted bits of the query string and set _quotedquery_
     313  text_t &arg_q = args["q"];
     314  if (!arg_q.empty()) {
     315
     316    text_t::const_iterator end = arg_q.end();
     317    text_t::const_iterator here = findchar (arg_q.begin(), end, '\"');
     318    if (here != end) {
     319      text_t quotedquery, tmptext;
     320      bool first = true;
     321      bool foundquote = false;
     322      while (here != end) {
     323    if (*here == '\"') {
     324      if (foundquote) {
     325        if (!tmptext.empty()) {
     326          if (!first) quotedquery += " and ";
     327          else first = false;
     328          quotedquery += "\"" + tmptext + "\"";
     329          tmptext.clear();
     330        }
     331        foundquote = false;
     332      } else foundquote = true;
     333    } else {
     334      if (foundquote) tmptext.push_back (*here);
     335    }
     336    here ++;
     337      }
     338      disp.setmacro ("quotedquery", "query", quotedquery);
     339    }
     340  }
    304341}
    305342
     
    405442    FilterRequest_t request;
    406443    FilterResponse_t response;
    407     text_t quotedstring;
    408444    format_t *formatlistptr = new format_t();
    409445
     
    412448    // do the query
    413449    request.filterResultOptions = FROID | FRmetadata | FRtermFreq;
    414     if (!do_query (request, args, collectproto, quotedstring, response, logout))
     450    if (!do_query (request, args, collectproto, response, logout))
    415451      return false;
    416452   
    417453    // set macros
    418     define_query_macros (args, disp, response, quotedstring);
     454    define_query_macros (args, disp, response);
    419455   
    420456    // output the header
     
    430466      textout << outconvert << disp << "<tr>\n"
    431467
    432 //            << "<td valign=top nowrap>r: " << (*this_doc).ranking
    433 //            << " t: " << (*this_doc).num_terms_matched << " p: "
    434 //            << (*this_doc).num_phrase_match << "</td>\n"
     468    //            << "<td valign=top nowrap>r: " << (*this_doc).ranking
     469    //            << " t: " << (*this_doc).num_terms_matched << " p: "
     470    //            << (*this_doc).num_phrase_match << "</td>\n"
    435471   
    436472          << get_formatted_string (*this_doc, formatlistptr) << "\n"
     
    454490// _thisfirst_, and _thislast_
    455491void queryaction::define_query_macros (cgiargsclass &args, displayclass &disp,
    456                        const FilterResponse_t &response,
    457                        const text_t &quotedstring) {
     492                       const FilterResponse_t &response) {
    458493
    459494  int numdocs = response.numDocs;
     
    472507  }
    473508 
    474   disp.setmacro ("quotedquery", "query", quotedstring);
    475509  disp.setmacro ("freqmsg", "query", freqmsg);
    476510
  • trunk/gsdl/src/recpt/queryaction.h

    r347 r397  
    2424
    2525  void define_query_macros (cgiargsclass &args, displayclass &disp,
    26                 const FilterResponse_t &response,
    27                 const text_t &quotedstring);
     26                const FilterResponse_t &response);
     27
    2828  void set_option_macro (const text_t &macroname, text_t current_value,
    2929             const FilterOption_t &option, displayclass &disp);
  • trunk/gsdl/src/recpt/querytools.cpp

    r349 r397  
    1212/*
    1313   $Log$
     14   Revision 1.3  1999/07/16 00:19:02  sjboddie
     15   some changes to the way quoted queries are handled
     16
    1417   Revision 1.2  1999/07/07 06:12:21  rjmcnab
    1518   Added ability to combine two independant queries.
     
    2932// request.filterResultOptions and request.fields (if required)
    3033// should be set by the calling function.
    31 // If the query string uses quotes (phrase-searching) the quoted
    32 // part of the string is returned in quotedstring (as something
    33 // of a side-effect ;-/
    3434
    3535bool do_query (FilterRequest_t &request, cgiargsclass &args,
    36            recptproto *collectproto, text_t &quotedstring,
    37            FilterResponse_t &response, ostream &logout) {
     36           recptproto *collectproto, FilterResponse_t &response,
     37           ostream &logout) {
    3838
    3939  request.filterName = "QueryFilter";
     
    4242  OptionValue_t option;
    4343  text_t formattedstring = args["q"];
    44 
    45   // format the query string ready to do the query (and remember
    46   // the quoted part for later)
    47   format_querystring (formattedstring, quotedstring);
    4844 
    4945  option.name = "Term";
     
    8783    request.filterOptions.push_back (option);
    8884   
    89     text_t quotedstring2;
    9085    text_t formattedstring2 = args["q2"];
    91     format_querystring (formattedstring2, quotedstring2);
     86    format_querystring (formattedstring2);
    9287
    9388    option.name = "Term";
     
    149144}
    150145
    151 void format_querystring (text_t &querystring, text_t &quotedstring) {
     146void format_querystring (text_t &querystring) {
    152147  text_t formattedstring;
    153   quotedstring.clear();
    154148
    155149  text_t::const_iterator here = querystring.begin();
    156150  text_t::const_iterator end = querystring.end();
    157   int foundquote = 0;
    158151
    159152  // space is used to insert spaces between Chinese
     
    169162      formattedstring.push_back(' ');
    170163    } else {
    171       if (*here == '"') {
    172     if (foundquote) {foundquote = 0; quotedstring.push_back(*here);}
    173     else foundquote = 1;
     164      if ((*here >= 0x4e00 && *here <= 0x9fa5) ||
     165      (*here >= 0xf900 && *here <= 0xfa2d)) {
     166    // Chinese character
     167    if (space) formattedstring.push_back (0x200b);
     168    formattedstring.push_back (*here);
     169    formattedstring.push_back (0x200b);
     170    space = true;
    174171      } else {
    175     if ((*here >= 0x4e00 && *here <= 0x9fa5) ||
    176         (*here >= 0xf900 && *here <= 0xfa2d)) {
    177       // Chinese character
    178       if (space) formattedstring.push_back (0x200b);
    179       formattedstring.push_back (*here);
    180       formattedstring.push_back (0x200b);
    181       space = true;
    182     } else {
    183       // non-Chinese character
    184       formattedstring.push_back (*here);
    185       space = false;
    186     }
     172    // non-Chinese character
     173    formattedstring.push_back (*here);
     174    space = false;
    187175      }
    188       if (foundquote) quotedstring.push_back(*here);
    189176    }
    190177    here ++;
    191178  }
    192   querystring = formattedstring + quotedstring;
     179  querystring = formattedstring;
    193180}
    194181
  • trunk/gsdl/src/recpt/querytools.h

    r270 r397  
    1818
    1919bool do_query (FilterRequest_t &request, cgiargsclass &args,
    20            recptproto *collectproto, text_t &quotedstring,
    21            FilterResponse_t &response, ostream &logout);
    22 void format_querystring (text_t &querystring, text_t &quotedstring);
     20           recptproto *collectproto, FilterResponse_t &response,
     21           ostream &logout);
     22void format_querystring (text_t &querystring);
    2323
    2424#endif
Note: See TracChangeset for help on using the changeset viewer.