|
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 /** 54 * Should this gazetteer only match whole words. The default value is 55 * <tt>true</tt>. 56 */ 57 protected Boolean wholeWordsOnly; 58 59 /** the linear definition of the gazetteer */ 60 protected LinearDefinition definition; 61 62 /** reference to mapping definiton info 63 * allows filling of Lookup.ontologyClass according to a list*/ 64 protected MappingDefinition mappingDefinition; 65 66 67 /** 68 * Sets the AnnotationSet that will be used at the next run for the newly 69 * produced annotations. 70 */ 71 public void setAnnotationSetName(String newAnnotationSetName) { 72 annotationSetName = newAnnotationSetName; 73 } 74 75 /** 76 * Gets the AnnotationSet that will be used at the next run for the newly 77 * produced annotations. 78 */ 79 public String getAnnotationSetName() { 80 return annotationSetName; 81 } 82 83 public void setEncoding(String newEncoding) { 84 encoding = newEncoding; 85 } 86 87 public String getEncoding() { 88 return encoding; 89 } 90 91 public java.net.URL getListsURL() { 92 return listsURL; 93 } 94 95 public void setListsURL(java.net.URL newListsURL) { 96 listsURL = newListsURL; 97 } 98 99 public void setCaseSensitive(Boolean newCaseSensitive) { 100 caseSensitive = newCaseSensitive; 101 } 102 103 public Boolean getCaseSensitive() { 104 return caseSensitive; 105 } 106 107 public void setMappingDefinition(MappingDefinition mapping) { 108 mappingDefinition = mapping; 109 } 110 111 public MappingDefinition getMappingDefinition(){ 112 return mappingDefinition; 113 } 114 115 /**Gets the linear definition of this gazetteer. there is no parallel 116 * set method because the definition is loaded through the listsUrl 117 * on init(). 118 * @return the linear definition of the gazetteer */ 119 public LinearDefinition getLinearDefinition() { 120 return definition; 121 } 122 123 /** */ 124 public FeatureMap getFeatures(){ 125 return features; 126 } // getFeatures 127 128 /** */ 129 public void setFeatures(FeatureMap features){ 130 this.features = features; 131 } // setFeatures 132 133 public void reInit() throws ResourceInstantiationException { 134 super.reInit(); 135 fireGazetteerEvent(new GazetteerEvent(this,GazetteerEvent.REINIT)); 136 }//reInit() 137 138 /** 139 * fires a Gazetteer Event 140 * @param ge Gazetteer Event to be fired 141 */ 142 public void fireGazetteerEvent(GazetteerEvent ge) { 143 Iterator li = listeners.iterator(); 144 while ( li.hasNext()) { 145 GazetteerListener gl = (GazetteerListener) li.next(); 146 gl.processGazetteerEvent(ge); 147 } 148 } 149 150 /** 151 * Registers a Gazetteer Listener 152 * @param gl Gazetteer Listener to be registered 153 */ 154 public void addGazetteerListener(GazetteerListener gl){ 155 if ( null!=gl ) 156 listeners.add(gl); 157 } 158 159 /** 160 * Gets the value for the {@link #wholeWordsOnly} parameter. 161 * @return a Boolean value. 162 */ 163 public Boolean getWholeWordsOnly() { 164 return wholeWordsOnly; 165 } 166 167 /** 168 * Sets the value for the {@link #wholeWordsOnly} parameter. 169 * @param wholeWordsOnly a Boolean value. 170 */ 171 public void setWholeWordsOnly(Boolean wholeWordsOnly) { 172 this.wholeWordsOnly = wholeWordsOnly; 173 } 174 175 }//class AbstractGazetteer
|
AbstractGazetteer |
|