|
AbstractGazetteer |
|
1 /* 2 * AbstractGazetteer.java 3 * 4 * Copyright (c) 2002, The University of Sheffield. 5 * 6 * This file is part of GATE (see http://gate.ac.uk/), and is free 7 * software, licenced under the GNU Library General Public License, 8 * Version 2, June1991. 9 * 10 * A copy of this licence is included in the distribution in the file 11 * licence.html, and is also available at http://gate.ac.uk/gate/licence.html. 12 * 13 * borislav popov 02/2002 14 * 15 */ 16 package gate.creole.gazetteer; 17 18 import gate.*; 19 import gate.creole.*; 20 import gate.util.*; 21 22 import java.util.*; 23 24 /**AbstractGazetteer 25 * This class implements the common-for-all methods of the Gazetteer interface*/ 26 public abstract class AbstractGazetteer 27 extends gate.creole.AbstractLanguageAnalyser implements Gazetteer { 28 29 /** the set of gazetteer listeners */ 30 protected Set listeners = new HashSet(); 31 32 /** Used to store the annotation set currently being used for the newly 33 * generated annotations*/ 34 protected String annotationSetName; 35 36 /** A map of the features */ 37 protected FeatureMap features = null; 38 39 /** the encoding of the gazetteer */ 40 protected String encoding = "UTF-8"; 41 42 /** 43 * The value of this property is the URL that will be used for reading the 44 * lists dtaht define this Gazetteer 45 */ 46 protected java.net.URL listsURL; 47 48 /** 49 * Should this gazetteer be case sensitive. The default value is true. 50 */ 51 protected Boolean caseSensitive = new Boolean(true); 52 53 /** the linear definition of the gazetteer */ 54 protected LinearDefinition definition; 55 56 /** reference to mapping definiton info 57 * allows filling of Lookup.ontologyClass according to a list*/ 58 protected MappingDefinition mappingDefinition; 59 60 /** 61 * Sets the AnnotationSet that will be used at the next run for the newly 62 * produced annotations. 63 */ 64 public void setAnnotationSetName(String newAnnotationSetName) { 65 annotationSetName = newAnnotationSetName; 66 } 67 68 /** 69 * Gets the AnnotationSet that will be used at the next run for the newly 70 * produced annotations. 71 */ 72 public String getAnnotationSetName() { 73 return annotationSetName; 74 } 75 76 public void setEncoding(String newEncoding) { 77 encoding = newEncoding; 78 } 79 80 public String getEncoding() { 81 return encoding; 82 } 83 84 public java.net.URL getListsURL() { 85 return listsURL; 86 } 87 88 public void setListsURL(java.net.URL newListsURL) { 89 listsURL = newListsURL; 90 } 91 92 public void setCaseSensitive(Boolean newCaseSensitive) { 93 caseSensitive = newCaseSensitive; 94 } 95 96 public Boolean getCaseSensitive() { 97 return caseSensitive; 98 } 99 100 public void setMappingDefinition(MappingDefinition mapping) { 101 mappingDefinition = mapping; 102 } 103 104 public MappingDefinition getMappingDefinition(){ 105 return mappingDefinition; 106 } 107 108 /**Gets the linear definition of this gazetteer. there is no parallel 109 * set method because the definition is loaded through the listsUrl 110 * on init(). 111 * @return the linear definition of the gazetteer */ 112 public LinearDefinition getLinearDefinition() { 113 return definition; 114 } 115 116 /** */ 117 public FeatureMap getFeatures(){ 118 return features; 119 } // getFeatures 120 121 /** */ 122 public void setFeatures(FeatureMap features){ 123 this.features = features; 124 } // setFeatures 125 126 public void reInit() throws ResourceInstantiationException { 127 super.reInit(); 128 fireGazetteerEvent(new GazetteerEvent(this,GazetteerEvent.REINIT)); 129 }//reInit() 130 131 /** 132 * fires a Gazetteer Event 133 * @param ge Gazetteer Event to be fired 134 */ 135 public void fireGazetteerEvent(GazetteerEvent ge) { 136 Iterator li = listeners.iterator(); 137 while ( li.hasNext()) { 138 GazetteerListener gl = (GazetteerListener) li.next(); 139 gl.processGazetteerEvent(ge); 140 } 141 } 142 143 /** 144 * Registers a Gazetteer Listener 145 * @param gl Gazetteer Listener to be registered 146 */ 147 public void addGazetteerListener(GazetteerListener gl){ 148 if ( null!=gl ) 149 listeners.add(gl); 150 } 151 }//class AbstractGazetteer
|
AbstractGazetteer |
|