Changeset 3800

Show
Ignore:
Timestamp:
05.03.2003 14:02:07 (17 years ago)
Author:
mdewsnip
Message:

Removed option to sort by rank/natural order, and added code to deal with term information and equivalent terms.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGSearch.java

    r3770 r3800  
    7171    private static final String INDEX_ELEM = "index"; 
    7272 
    73     public static final String COUNT_ATT = "count"; 
    74     public static final String STEM_ATT = "stem"; 
     73    private static final String EQUIV_TERM_ELEM = "equivTerm"; 
     74 
     75    private static final String STEM_ATT = "stem"; 
     76    private static final String NUM_DOCS_MATCH_ATT = "numDocsMatch"; 
     77    private static final String FREQ_ATT = "freq"; 
    7578 
    7679    private MGWrapper mg_src_ = null; 
     
    186189        }    
    187190    } 
    188     else if (name.equals(RANK_PARAM)) { 
    189         String[] vals1 = {RANK_PARAM_RANK, RANK_PARAM_NONE }; 
    190         if (display) { 
    191         String[] vals1_texts = { getTextString("param."+RANK_PARAM+"."+RANK_PARAM_RANK, lang), 
    192                       getTextString("param."+RANK_PARAM+"."+RANK_PARAM_NONE, lang)}; 
    193          
    194         param = GSXML.createParameterDisplay(doc_, RANK_PARAM, getTextString("param."+RANK_PARAM, lang), vals1, vals1_texts); 
    195         } else { 
    196         param = GSXML.createParameter(doc_, RANK_PARAM, GSXML.PARAM_TYPE_ENUM_SINGLE, RANK_PARAM_RANK, vals1 ); 
    197         } 
    198     } 
    199191    else if (name.equals(MAXDOCS_PARAM)) { 
    200192        if (display) { 
     
    231223    createParameter(STEM_PARAM, param_list, display, lang); 
    232224    createParameter(MATCH_PARAM, param_list, display, lang); 
    233     createParameter(RANK_PARAM, param_list, display, lang); 
    234225    createParameter(MAXDOCS_PARAM, param_list, display, lang); 
    235226    createParameter(QUERY_PARAM, param_list, display, lang); 
     
    262253    result.setAttribute(GSXML.FROM_ATT, from); 
    263254    result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_QUERY); 
    264     // result.setAttribute(GSXML.NAME_ATT, TEXT_QUERY_SERVICE); 
    265255 
    266256    // get param list 
     
    281271        index = default_index_; 
    282272    } 
    283     // System.out.println("Index: " + index); 
    284273 
    285274    // now set up the mg stuff 
     
    314303    num_matches_elem.setAttribute(GSXML.VALUE_ATT, "" + totalDocs); 
    315304    metadata_list.appendChild(num_matches_elem); 
    316     // System.out.println("Metadata list: " + converter_.getString(metadata_list)); 
    317305 
    318306    // Response content: documents and terms 
     
    336324    Vector terms = mqr.getTerms(); 
    337325    for (int t = 0; t < terms.size(); t++) { 
    338         String term = ((MGTermInfo) terms.elementAt(t)).term_; 
    339         long term_freq = ((MGTermInfo) terms.elementAt(t)).term_freq_; 
    340         int stem_method = ((MGTermInfo) terms.elementAt(t)).stem_method_; 
     326        MGTermInfo term_info = (MGTermInfo) terms.get(t); 
     327 
     328        String term = term_info.term_; 
     329        int stem_method = term_info.stem_method_; 
     330        Vector equiv_terms = term_info.equiv_terms_; 
    341331 
    342332        Element term_elem = doc_.createElement(GSXML.TERM_ELEM); 
    343333        term_elem.setAttribute(GSXML.NAME_ATT, term); 
    344         term_elem.setAttribute(COUNT_ATT, "" + term_freq); 
    345334        term_elem.setAttribute(STEM_ATT, "" + stem_method); 
     335 
     336        Element equiv_term_list = doc_.createElement(EQUIV_TERM_ELEM+GSXML.LIST_MODIFIER); 
     337        term_elem.appendChild(equiv_term_list); 
     338 
     339        long total_term_freq = 0; 
     340        for (int et = 0; et < equiv_terms.size(); et++) { 
     341        MGEquivTermInfo equiv_term_info = (MGEquivTermInfo) equiv_terms.get(et); 
     342 
     343        Element equiv_term_elem = doc_.createElement(GSXML.TERM_ELEM); 
     344        equiv_term_elem.setAttribute(GSXML.NAME_ATT, equiv_term_info.term_); 
     345        equiv_term_elem.setAttribute(NUM_DOCS_MATCH_ATT, "" + equiv_term_info.match_docs_); 
     346        equiv_term_elem.setAttribute(FREQ_ATT, "" + equiv_term_info.term_freq_); 
     347        equiv_term_list.appendChild(equiv_term_elem); 
     348 
     349        total_term_freq += equiv_term_info.term_freq_; 
     350        } 
     351 
     352        term_elem.setAttribute(FREQ_ATT, "" + total_term_freq); 
    346353        term_list.appendChild(term_elem); 
    347354    } 
     
    377384        mg_src_.setMatchMode(mode); 
    378385        } 
    379         else if (name.equals(RANK_PARAM)) { 
    380         if (value.equals(RANK_PARAM_RANK)) { 
    381             mg_src_.setSortByRank(true); 
    382         } else if (value.equals(RANK_PARAM_NONE)) { 
    383             mg_src_.setSortByRank(false); 
    384         } 
    385         } 
    386386        else if (name.equals(MAXDOCS_PARAM)) { 
    387387        int docs = Integer.parseInt(value);