Show
Ignore:
Timestamp:
05.09.2013 13:35:43 (6 years ago)
Author:
kjdon
Message:

tidying up for case/accent/stem checkboxes in advance mgpp search form. adding in accent fold one. making these boxes display or not based on whether these options are available in the collection

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/recpt/querytools.cpp

    r27066 r28221  
    519519} 
    520520 
    521 // Parses the terms into words, and adds #si if necessary 
    522 text_t addstemcase(const text_t &terms, const text_t &stem, const text_t &fold, 
     521// Parses the terms into words, and adds #sif if necessary 
     522text_t addstemcase(const text_t &terms, const text_t &stem, const text_t &casefold, const text_t &accentfold, 
    523523           const int indexer_type) { 
    524524   
    525   // the default stem and case are set to 0 if this is being used, so we are only adding on qualifiers if stem or fold is 1. 
    526   if (stem == "0" && fold == "0") { 
     525  // the default stem, case and accentfold are set to 0 if this is being used, so we are only adding on qualifiers if stem,case,accent is 1. 
     526  if (stem == "0" && casefold == "0" && accentfold =="0") { 
    527527    return terms; 
    528528  } 
     
    537537  text_t::const_iterator here = terms.begin(); 
    538538  text_t::const_iterator end = terms.end(); 
     539 
     540  text_t word_modifier = "#"; 
     541  if (stem == "1") word_modifier += "s"; 
     542  if (casefold == "1") word_modifier += "i"; 
     543  if (accentfold == "1") word_modifier += "f"; 
    539544 
    540545  while (here !=end) { 
     
    553558    } 
    554559    else { 
    555       word += "#"; 
    556       if (stem == "1") word += "s"; 
    557       if (fold == "1") word += "i"; 
    558       outtext += word; 
     560      outtext += word+word_modifier; 
    559561      word.clear(); 
    560562    } 
     
    571573  // get last word 
    572574  if (!word.empty()) { 
    573     word += "#"; 
    574     if (stem == "1") word += "s"; 
    575     if (fold == "1") word += "i"; 
    576     word += " "; 
    577     outtext += word; 
     575   outtext += word+word_modifier+" "; 
    578576  } 
    579577  return outtext; 
     
    667665 
    668666  text_tarray stems; 
    669   text_tarray folds; 
     667  text_tarray casefolds; 
     668  text_tarray accentfolds; 
    670669  if (argct == 1) {// mgpp - lucene doesn't do stem/case 
    671     text_t stem = args["fqs"]; 
    672     if (stem.empty()) return; // somethings wrong 
    673     splitchar(stem.begin(), stem.end(), ',', stems); 
    674      
    675     text_t fold = args["fqk"]; 
    676     if (fold.empty()) return; // somethings wrong 
    677     splitchar(fold.begin(), fold.end(), ',', folds); 
     670    if (args["ss"]=="1") { //collection has stemming 
     671      text_t stem = args["fqs"]; 
     672      if (stem.empty()) return; // somethings wrong 
     673      splitchar(stem.begin(), stem.end(), ',', stems); 
     674    } 
     675    if (args["ks"]=="1") { // collection has case folding 
     676      text_t fold = args["fqk"]; 
     677      if (fold.empty()) return; // somethings wrong 
     678      splitchar(fold.begin(), fold.end(), ',', casefolds); 
     679    } 
     680    if (args["afs"]=="1") { 
     681      text_t accent = args["fqaf"]; 
     682      if (accent.empty()) return; // somethings wrong 
     683      splitchar(accent.begin(), accent.end(), ',', accentfolds); 
     684    } 
    678685  } 
    679686   
     
    696703      format_querystring(this_value, argb, segment);  
    697704      if (argct == 1) { // mgpp only 
    698     this_value = addstemcase(this_value, stems[i], folds[i], argct); 
     705    this_value = addstemcase(this_value, ((args["ss"]=="1")?stems[i]:"0"), ((args["ks"]=="1")?casefolds[i]:"0"), ((args["afs"]=="1")?accentfolds[i]:"0"), argct); 
    699706      } 
    700707      // add tag info for this field (and other processing)