Changeset 4018
- Timestamp:
- 2003-03-27T15:16:59+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GATEServices.java
r4015 r4018 25 25 // GATE classes 26 26 import gate.*; 27 import gate.creole.*; 27 28 import gate.gui.*; 28 29 import gate.util.persistence.PersistenceManager; … … 36 37 import java.io.File; 37 38 import java.net.URL; 39 import java.util.Collection; 38 40 import java.util.HashSet; 39 41 import java.util.Iterator; … … 57 59 protected static final String GATE_POS_TAG_SERVICE = "GatePOSTag"; 58 60 61 protected static final String ANNOTATION_TYPE_PARAM = "annotationType"; 62 59 63 protected Element config_info_ = null; 60 64 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" }; 64 71 65 72 … … 88 95 Element tq_service_full = (Element) tq_service.cloneNode(true); 89 96 Element param_list = doc_.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 97 createParameter(ANNOTATION_TYPE_PARAM, param_list, false, null); 90 98 tq_service_full.appendChild(param_list); 91 99 service_info_map_.put(GATE_POS_TAG_SERVICE, tq_service_full); … … 110 118 URL applicationFileURL = ClassLoader.getSystemResource("gate.app"); 111 119 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 } */ 113 133 114 134 // Create a new corpus 115 corpus = Factory.newCorpus("GSDL3 Corpus");116 application .setCorpus(corpus);135 corpus_ = Factory.newCorpus("GSDL3 Corpus"); 136 application_.setCorpus(corpus_); 117 137 } 118 138 catch (Exception e) { … … 133 153 display.appendChild(GSXML.createTextElement(doc_, GSXML.DISPLAY_SUBMIT_ELEM, getTextString(service+".submit", lang))); 134 154 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 135 160 return display; 136 161 } … … 143 168 Element param = null; 144 169 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 159 177 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 } 165 189 } 166 190 … … 240 264 241 265 // Add it to the corpus 242 corpus .clear();243 corpus .add(doc);266 corpus_.clear(); 267 corpus_.add(doc); 244 268 245 269 // Process the corpus 246 application .execute();270 application_.execute(); 247 271 248 272 // Extract all the annotations
Note:
See TracChangeset
for help on using the changeset viewer.