Changeset 7197 for trunk


Ignore:
Timestamp:
2004-04-07T16:12:21+12:00 (20 years ago)
Author:
kjdon
Message:

made a couple of mods so that keiko's japanese segmentation will work, and show up as a phrase search

File:
1 edited

Legend:

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

    r7067 r7197  
    551551  // define_internal_macros sets the following macros:
    552552
    553   // _quotedquery_  the part of the query string that was quoted for post-processing
    554 
    555 
    556 
    557553  // The following macros are set later (in define_query_macros) as they can't be set until
    558554  // the query has been done.
    559 
     555  // _quotedquery_   the part of the query string that was quoted for post-processing
    560556  // _freqmsg_      the term frequency string
    561557
     
    568564  // _thisfirst_
    569565  // _thislast_
    570 
    571   if (args["ct"]==0) { // mg queries only, not mgpp
    572     // get the quoted bits of the query string and set _quotedquery_
    573     text_tarray phrases;
    574     get_phrases (args["q"], phrases);
    575     num_phrases = phrases.size();
    576     text_tarray::const_iterator phere = phrases.begin();
    577     text_tarray::const_iterator pend = phrases.end();
    578     bool first = true;
    579     text_t quotedquery;
    580     while (phere != pend) {
    581       if (!first)
    582     if ((phere +1) == pend) quotedquery += " and ";
    583     else quotedquery += ", ";
    584      
    585       quotedquery += "\"" + *phere + "\"";
    586       first = false;
    587       phere ++;
    588     }
    589     if (args.getintarg("s") && !quotedquery.empty()) quotedquery += "_textstemon_";
    590     disp.setmacro ("quotedquery", "query", quotedquery);
    591   }
    592566
    593567  define_form_macros(disp, args, protos, logout);
     
    13741348  if (args["qt"]=="0" && args["qto"] != "2") { // normal text search
    13751349    formattedstring = args["q"];
    1376     // remove & | ! for simple search, insert spaces for chinese
     1350    // remove & | ! for simple search,do segmentation if necessary
    13771351    format_querystring (formattedstring, args.getintarg("b"), segment);
    13781352    if (args["ct"]=="1") { // mgpp - we need to add in the field info
     
    13941368    parse_adv_query_form(formattedstring, args);
    13951369      }
    1396       args["q"] = formattedstring;
    1397      
    13981370      // reset the cgiargfqv macro - need to escape any quotes in it
    13991371      disp.setmacro("cgiargfqv", "query", escape_quotes(args["fqv"]));
    1400 
    1401       // also reset the _cgiargq_ macro as it has changed now
    1402       disp.setmacro("cgiargq", "Global", html_safe(args["q"]));
    1403      
    1404       // reset the compressed options to include the q arg
    1405       text_t compressedoptions = recpt->get_compressed_arg(args, logout);
    1406       if (!compressedoptions.empty()) {
    1407     disp.setmacro ("compressedoptions", "Global", dm_safe(compressedoptions));
    1408     // need a decoded version of compressedoptions for use within forms
    1409     // as browsers encode values from forms before sending to server
    1410     // (e.g. %25 becomes %2525)
    1411     decode_cgi_arg (compressedoptions);
    1412     disp.setmacro ("decodedcompressedoptions", "Global", dm_safe(compressedoptions));
    1413       }
    1414     } // form search
    1415   } // args["qt"]=1
    1416   else {
     1372    }
     1373  } else {
    14171374    logout << "ERROR (query_action::get_formatted_query_string): querytype not defined\n";
     1375    return;
     1376  }
     1377 
     1378  // reset the query arg in case it has changed
     1379  args["q"] = formattedstring;
     1380 
     1381  // also reset the _cgiargq_ macro as it has changed now
     1382  disp.setmacro("cgiargq", "Global", html_safe(args["q"]));
     1383 
     1384  // reset the compressed options to include the q arg
     1385  text_t compressedoptions = recpt->get_compressed_arg(args, logout);
     1386  if (!compressedoptions.empty()) {
     1387    disp.setmacro ("compressedoptions", "Global", dm_safe(compressedoptions));
     1388    // need a decoded version of compressedoptions for use within forms
     1389    // as browsers encode values from forms before sending to server
     1390    // (e.g. %25 becomes %2525)
     1391    decode_cgi_arg (compressedoptions);
     1392    disp.setmacro ("decodedcompressedoptions", "Global", dm_safe(compressedoptions));
    14181393  }
    14191394}
     
    14731448    disp.setmacro ("nextlast", "query", nextlast);
    14741449  }
     1450
     1451  // do quoted query here cos we may have added quotes during query pre-processing
     1452  if (args["ct"]==0) { // mg queries only, not mgpp
     1453    // get the quoted bits of the query string and set _quotedquery_
     1454    text_tarray phrases;
     1455    get_phrases (args["q"], phrases);
     1456    num_phrases = phrases.size();
     1457    text_tarray::const_iterator phere = phrases.begin();
     1458    text_tarray::const_iterator pend = phrases.end();
     1459    bool first = true;
     1460    text_t quotedquery;
     1461    while (phere != pend) {
     1462      if (!first)
     1463    if ((phere +1) == pend) quotedquery += " and ";
     1464    else quotedquery += ", ";
     1465     
     1466      quotedquery += "\"" + *phere + "\"";
     1467      first = false;
     1468      phere ++;
     1469    }
     1470    if (args.getintarg("s") && !quotedquery.empty()) quotedquery += "_textstemon_";
     1471    disp.setmacro ("quotedquery", "query", quotedquery);
     1472  }
     1473
    14751474}
    14761475
Note: See TracChangeset for help on using the changeset viewer.