Changeset 4018


Ignore:
Timestamp:
2003-03-27T15:16:59+12:00 (21 years ago)
Author:
mdewsnip
Message:

Added parameter description.

File:
1 edited

Legend:

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

    r4015 r4018  
    2525// GATE classes
    2626import gate.*;
     27import gate.creole.*;
    2728import gate.gui.*;
    2829import gate.util.persistence.PersistenceManager;
     
    3637import java.io.File;
    3738import java.net.URL;
     39import java.util.Collection;
    3840import java.util.HashSet;
    3941import java.util.Iterator;
     
    5759    protected static final String GATE_POS_TAG_SERVICE = "GatePOSTag";
    5860
     61    protected static final String ANNOTATION_TYPE_PARAM = "annotationType";
     62
    5963    protected Element config_info_ = null;
    6064
    61     protected CorpusController application;
    62 
    63     protected Corpus corpus;
     65    protected CorpusController application_;
     66
     67    protected Corpus corpus_;
     68
     69    protected String[] annotation_types_ = { "Address", "Date", "Location",
     70                         "Organization", "Person" };
    6471
    6572
     
    8895    Element tq_service_full = (Element) tq_service.cloneNode(true);
    8996    Element param_list = doc_.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     97    createParameter(ANNOTATION_TYPE_PARAM, param_list, false, null);
    9098    tq_service_full.appendChild(param_list);
    9199    service_info_map_.put(GATE_POS_TAG_SERVICE, tq_service_full);
     
    110118        URL applicationFileURL = ClassLoader.getSystemResource("gate.app");
    111119        File applicationFile = new File(applicationFileURL.getFile());
    112         application = (CorpusController) PersistenceManager.loadObjectFromFile(applicationFile);
     120        application_ = (CorpusController) PersistenceManager.loadObjectFromFile(applicationFile);
     121
     122        /* Collection processing_resources = application.getPRs();
     123        Iterator pr_iterator = processing_resources.iterator();
     124        while (pr_iterator.hasNext()) {
     125        ProcessingResource pr = (ProcessingResource) pr_iterator.next();
     126        String pr_name = pr.getName();
     127        System.out.println("PR name: " + pr_name);
     128        if (pr_name.startsWith("ANNIE POS Tagger")) {
     129            String as_name = ((POSTagger) pr).getInputASName();
     130            System.out.println("AS name: " + as_name);
     131        }
     132        } */
    113133
    114134        // Create a new corpus
    115         corpus = Factory.newCorpus("GSDL3 Corpus");
    116         application.setCorpus(corpus);
     135        corpus_ = Factory.newCorpus("GSDL3 Corpus");
     136        application_.setCorpus(corpus_);
    117137    }
    118138    catch (Exception e) {
     
    133153    display.appendChild(GSXML.createTextElement(doc_, GSXML.DISPLAY_SUBMIT_ELEM, getTextString(service+".submit", lang)));
    134154
     155    // now need to add in the params
     156    if (service.equals(GATE_POS_TAG_SERVICE)) {
     157        createParameter(ANNOTATION_TYPE_PARAM, display, true, lang);
     158    }
     159
    135160    return display;
    136161    }
     
    143168    Element param = null;
    144169
    145     // the index info - read from config file
    146     /* Element index_list = (Element)GSXML.getChildByTagName(config_info_, INDEX_ELEM+GSXML.LIST_MODIFIER);
    147     NodeList indexes = index_list.getElementsByTagName(INDEX_ELEM);
    148     int len = indexes.getLength();
    149     if (len > 1) { // add index param to list only if more than one index specified
    150         String [] inds  = new String[len];
    151         String [] ind_names = new String[len];
    152         for (int i=0; i<len; i++) {
    153         inds[i] = ((Element)indexes.item(i)).getAttribute(GSXML.NAME_ATT);
    154         if (display) {
    155             Element disp = (Element)GSXML.getChildByTagName(indexes.item(i), GSXML.DISPLAY_ELEM);
    156             ind_names[i] = GSXML.getDisplayText(disp, GSXML.DISPLAY_NAME_ELEM, lang, "en");
    157         }
    158         }
     170    if (name.equals(ANNOTATION_TYPE_PARAM)) {
     171        int len = annotation_types_.length;
     172        String[] annotation_type_names = new String[len];
     173        for (int i = 0; i < len; i++) {
     174        annotation_type_names[i] = getTextString("param." + name + "." + annotation_types_[i], lang);
     175        }
     176
    159177        if (display) {
    160         param = GSXML.createParameterDisplay(doc_, INDEX_PARAM, getTextString("param."+INDEX_PARAM, lang), inds, ind_names);
    161         } else {
    162         param = GSXML.createParameter(doc_, INDEX_PARAM, GSXML.PARAM_TYPE_ENUM_SINGLE, default_index_, inds);
    163         }
    164         } */
     178        param = GSXML.createParameterDisplay(doc_, name, getTextString("param." + name, lang), annotation_types_, annotation_type_names);
     179        }
     180        else {
     181        param = GSXML.createParameter(doc_, name, GSXML.PARAM_TYPE_ENUM_SINGLE, annotation_types_[0], annotation_types_);
     182        }
     183    }
     184
     185    // Add the parameter to the list
     186    if (param != null) {
     187        param_list.appendChild(param);
     188    }   
    165189    }
    166190
     
    240264
    241265        // Add it to the corpus
    242         corpus.clear();
    243         corpus.add(doc);
     266        corpus_.clear();
     267        corpus_.add(doc);
    244268
    245269        // Process the corpus
    246         application.execute();
     270        application_.execute();
    247271
    248272        // Extract all the annotations
Note: See TracChangeset for help on using the changeset viewer.