public class Span extends Object
child.from >= parent.from && child.to <= parent.to && (child.to-child.from) < (parent.to-parent.from)
This means that all spans on a text can be modeled as a tree, where all child spans are guaranteed to be contained
inside its parent span.
A span will usually be used indirectly through Interpretation.
Modifier and Type | Method and Description |
---|---|
Annotations |
annotate(AnnotationClass clazz) |
Annotations |
annotate(int from,
int to,
AnnotationClass clazz)
This will either create or get the annotation of the class annotation
|
Map<AnnotationClass,List<Annotations>> |
getAllAnnotations()
Returns all annotations that are contained in either this subspan or in any of its subannotations
|
Annotations |
getAnnotation(AnnotationClass clazz)
Returns the annotations with a specific class for the area defined by this span
|
Annotations |
getAnnotation(int from,
int to,
AnnotationClass clazz)
Returns the annotations with a specific class for the area defined by (from,to).
|
Set<AnnotationClass> |
getClasses()
Returns all AnnotationClasses that are defined for this span and any of its superspans.
|
Set<AnnotationClass> |
getClasses(int from,
int to)
Returns all AnnotationClasses that are defined for the range (from,to).
|
int |
getFrom()
hack
|
List<Span> |
getSubSpans()
Returns all spans that are directly childrens of this span.
|
List<Span> |
getTermSpans(String term)
Returns all spans, either this or any of the spans that are inherits this span that match the given term
|
String |
getText()
Returns the text that this spans is
|
int |
getTo()
hack
|
List<Span> |
getTokens()
Returns an unmodifiable list of all spans below this span that is a leaf node
|
boolean |
hasClass(AnnotationClass clazz)
Returns true if this class
|
String |
toString() |
public String getText()
public Annotations annotate(AnnotationClass clazz)
public Annotations annotate(int from, int to, AnnotationClass clazz)
public Map<AnnotationClass,List<Annotations>> getAllAnnotations()
public List<Span> getTermSpans(String term)
public Annotations getAnnotation(AnnotationClass clazz)
This function will query its parent to find any annotation that is set for an area that this span is contained in. If there are conflicts (several annotations defined with the same annotation class), the annotation that is defined for the smallest area (furthest down in the tree), is used.
public Annotations getAnnotation(int from, int to, AnnotationClass clazz)
RuntimeException
- if (from,to) is not contained in the spanpublic Set<AnnotationClass> getClasses()
public Set<AnnotationClass> getClasses(int from, int to)
RuntimeException
- if (from,to) is not contained in the spanpublic List<Span> getTokens()
public boolean hasClass(AnnotationClass clazz)
public List<Span> getSubSpans()
public int getFrom()
public int getTo()
Copyright © 2018. All rights reserved.