Return the document text as a String corresponding to the annotation. @param doc the document from which to extract the document text @param ann the annotation for which to return the text. @return a String representing the text content spanned by the annotation.
(
Document doc, SimpleAnnotation ann)
| 148 | * @return a String representing the text content spanned by the annotation. |
| 149 | */ |
| 150 | public static String stringFor( |
| 151 | Document doc, SimpleAnnotation ann) { |
| 152 | try { |
| 153 | return doc.getContent().getContent( |
| 154 | ann.getStartNode().getOffset(), |
| 155 | ann.getEndNode().getOffset()).toString(); |
| 156 | } catch(gate.util.InvalidOffsetException ex) { |
| 157 | throw new GateRuntimeException(ex.getMessage(),ex); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | |
| 162 | /** |