Changeset 26344 for main/trunk


Ignore:
Timestamp:
2012-10-18T14:24:27+13:00 (12 years ago)
Author:
kjdon
Message:

fiddling with index options (stem, case, accent). can now set the default value in collectionCOnfig.xml by adding default=on/off to the indexOption element

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2TextSearch.java

    r26130 r26344  
    5252
    5353    // stem indexes available
    54     protected boolean does_case = true;
    55     protected boolean does_stem = true;
     54    protected boolean does_case = false;
     55    protected boolean does_stem = false;
    5656    protected boolean does_accent = false;
    5757
     58  // default values for stem indexes
     59  protected String case_default = BOOLEAN_PARAM_ON;
     60  protected String accent_default = BOOLEAN_PARAM_ON;
     61  protected String stem_default = BOOLEAN_PARAM_OFF;
    5862    // maxnumeric -
    5963    protected int maxnumeric = 4;
     
    161165                {
    162166                    int stemindex = Integer.parseInt(value);
    163                     // stem and case are true by default, accent folding false by default
    164                     if ((stemindex & 1) == 0)
    165                     {
    166                         does_case = false;
    167                     }
    168                     if ((stemindex & 2) == 0)
    169                     {
    170                         does_stem = false;
     167                    if ((stemindex & 1) != 0)
     168                    {
     169                        does_case = true;
     170                    }
     171                    if ((stemindex & 2) != 0)
     172                    {
     173                        does_stem = true;
    171174                    }
    172175                    if ((stemindex & 4) != 0)
     
    183186            Document owner = info.getOwnerDocument();
    184187            Element config_search = (Element) GSXML.getChildByTagName(extra_info, GSXML.SEARCH_ELEM);
     188
     189            // work out what the default values for the stemming options are
     190            if (does_case || does_accent || does_stem) {
     191              // only bother looking for this is we have some of these set
     192              NodeList index_options = config_search.getElementsByTagName(GSXML.INDEX_OPTION_ELEM);
     193              for (int i = 0; i < index_options.getLength(); i++) {
     194                Element ind = (Element) index_options.item(i);
     195                String name = ind.getAttribute(GSXML.NAME_ATT);
     196                String def_val = ind.getAttribute(GSXML.DEFAULT_ATT);
     197
     198                if (!def_val.equals("")) {
     199                  if (name.equals("stem")) {
     200                stem_default = (def_val.equals("on")? BOOLEAN_PARAM_ON: BOOLEAN_PARAM_OFF);
     201                  } else if (name.equals("casefold")) {
     202                case_default = (def_val.equals("on")? BOOLEAN_PARAM_ON: BOOLEAN_PARAM_OFF);
     203                  } else if (name.equals("accentfold")) {
     204                accent_default = (def_val.equals("on")? BOOLEAN_PARAM_ON: BOOLEAN_PARAM_OFF);
     205                  }
     206                }
     207              }
     208            }
    185209
    186210            // so far we have index and indexSubcollection specific display elements, and global format elements
     
    330354        if (this.does_case)
    331355        {
    332             // gs2 has case on by default
    333             createParameter(CASE_PARAM, param_list, lang, BOOLEAN_PARAM_ON);
     356            createParameter(CASE_PARAM, param_list, lang, case_default);
    334357        }
    335358        if (this.does_stem)
    336359        {
    337             // but stem is off by default
    338             createParameter(STEM_PARAM, param_list, lang, BOOLEAN_PARAM_OFF);
     360            createParameter(STEM_PARAM, param_list, lang, stem_default);
    339361        }
    340362        if (this.does_accent)
    341363        {
    342             // and so is accent folding
    343             createParameter(ACCENT_PARAM, param_list, lang, BOOLEAN_PARAM_OFF);
     364            createParameter(ACCENT_PARAM, param_list, lang, accent_default);
    344365        }
    345366        createParameter(MATCH_PARAM, param_list, lang);
Note: See TracChangeset for help on using the changeset viewer.