001 /*
002 * PatternAnnotation.java
003 *
004 * Niraj Aswani, 19/March/07
005 *
006 * $Id: PatternAnnotation.html,v 1.0 2007/03/19 16:22:01 niraj Exp $
007 */
008 package gate.creole.annic;
009
010 import java.io.Serializable;
011 import java.util.HashMap;
012 import java.util.Map;
013
014 /**
015 * Pattern Annotation is similar to a GATE Annotation except that it
016 * doesn't have any annotation ID but it contains its position in the token stream
017 * that is created when indexing documents.
018 *
019 * @author niraj
020 *
021 */
022 public class PatternAnnotation implements Serializable {
023
024 /**
025 * serial version id
026 */
027 private static final long serialVersionUID = 3690197637685197108L;
028
029 /**
030 * Annotation Type
031 */
032 private String type;
033
034 /**
035 * Text of the annotation
036 */
037 private String text;
038
039 /**
040 * Start Offset
041 */
042 private int stOffset;
043
044 /**
045 * End Offset
046 */
047 private int enOffset;
048
049 /**
050 * FeatureMap
051 */
052 private Map<String, String> features;
053
054 /**
055 * Position in the token stream
056 */
057 private int position = 0;
058
059 /**
060 * Constructor
061 */
062 public PatternAnnotation() {
063 features = new HashMap<String, String>();
064 }
065
066 /**
067 * Sets the Type
068 * @param type
069 */
070 public void setType(String type) {
071 this.type = type;
072 }
073
074 /**
075 * Sets the TExt
076 * @param text
077 */
078 public void setText(String text) {
079 this.text = text;
080 }
081
082 /**
083 * Sets the start offset
084 * @param st
085 */
086 public void setStOffset(int st) {
087 this.stOffset = st;
088 }
089
090 /**
091 * Sets the end offset
092 * @param en
093 */
094 public void setEnOffset(int en) {
095 this.enOffset = en;
096 }
097
098 /**
099 * Adds a feature
100 * @param key
101 * @param val
102 */
103 public void addFeature(String key, String val) {
104 features.put(key, val);
105 }
106
107 /**
108 * Sets the position
109 * @param pos
110 */
111 public void setPosition(int pos) {
112 position = pos;
113 }
114
115 /**
116 * Gets the Features
117 * @return
118 */
119 public Map<String, String> getFeatures() {
120 return features;
121 }
122
123 /**
124 * Gets the value of a feature
125 * @param key
126 * @return
127 */
128 public String getFeature(String key) {
129 return (String)features.get(key);
130 }
131
132 /**
133 * Gets the type of the annotation
134 * @return
135 */
136 public String getType() {
137 return this.type;
138 }
139
140 /**
141 * Gets the text of the annotation
142 * @return
143 */
144 public String getText() {
145 return this.text;
146 }
147
148 /**
149 * Gets the start offset
150 * @return
151 */
152 public int getStartOffset() {
153 return stOffset;
154 }
155
156 /**
157 * Gets the end offset
158 * @return
159 */
160 public int getEndOffset() {
161 return enOffset;
162 }
163
164 /**
165 * Gets the position of this annotation in the token stream.
166 * @return
167 */
168 public int getPosition() {
169 return position;
170 }
171 }
|