public class AnnotatedText extends Object
Constructor and Description |
---|
AnnotatedText(String text) |
Modifier and Type | Method and Description |
---|---|
void |
addAnnotation(Annotation annotation) |
AnnotatedText |
detach(Annotation inputAnnotation)
Detach text and annotations covered by inputAnnotation into it's own AnnotatedText
instance with annotation offsets correctly set relative to detached text
|
boolean |
equals(Object obj) |
List<Annotation> |
getAnnotationsAsList()
Return all annotations in a flat list
Annotations of all types are mixed together and no guarantees are given with regards to order.
|
Map<String,List<Annotation>> |
getAnnotationsBetweenCharOffsets(int startTokenOffset,
int endTokenOffset,
boolean enclosed) |
List<Annotation> |
getAnnotationsBetweenCharOffsetsByType(int startTokenOffset,
int endTokenOffset,
String type,
boolean enclosed)
Get all annotations for given type that are either enclosed or connected to supplied start/end token offsets
See https://github.com/google/guava/wiki/RangesExplained#interval-operations for difference between enclosed/connected ranges
|
List<Annotation> |
getAnnotationsByType(String type) |
Map<String,List<Annotation>> |
getConnectedAnnotations(Annotation annotation)
Get all annotations connected to the input annotation's offsets.
|
Map<String,List<Annotation>> |
getCoveredAnnotations(Annotation annotation)
Get all annotations covered by the input annotation's offsets
For example, pass in a sentence annotation and to retrieve all annotations
within that sentence
|
String |
getCoveredText(Annotation annotation) |
List<Annotation> |
getCoveredTokens(Annotation annotation) |
String |
getText() |
List<Annotation> |
getTokens() |
List<Annotation> |
getTokensBetweenCharOffsets(int startCharOffset,
int endCharOffset)
Get all tokens that are completely enclosed by start / end character offsets
|
int |
hashCode() |
public AnnotatedText(String text)
public String getText()
public void addAnnotation(Annotation annotation)
public List<Annotation> getTokens()
public List<Annotation> getCoveredTokens(Annotation annotation)
public Map<String,List<Annotation>> getCoveredAnnotations(Annotation annotation)
annotation
- public Map<String,List<Annotation>> getConnectedAnnotations(Annotation annotation)
annotation
- public List<Annotation> getTokensBetweenCharOffsets(int startCharOffset, int endCharOffset)
startCharOffset
- endCharOffset
- public Map<String,List<Annotation>> getAnnotationsBetweenCharOffsets(int startTokenOffset, int endTokenOffset, boolean enclosed)
public List<Annotation> getAnnotationsBetweenCharOffsetsByType(int startTokenOffset, int endTokenOffset, String type, boolean enclosed)
startTokenOffset
- endTokenOffset
- type
- enclosed
- public List<Annotation> getAnnotationsByType(String type)
public String getCoveredText(Annotation annotation)
public AnnotatedText detach(Annotation inputAnnotation)
inputAnnotation
- public List<Annotation> getAnnotationsAsList()