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 | Field and Description |
---|---|
private Map<AnnotationClass,Annotations> |
annotations |
private int |
from |
private Modification |
modification |
private Span |
parent |
private List<Span> |
subSpans |
private int |
to |
Modifier | Constructor and Description |
---|---|
private |
Span(int from,
int to,
Span parent) |
(package private) |
Span(Modification modification)
Creates a new root span based on the modfication
|
Modifier and Type | Method and Description |
---|---|
private Annotations |
addAnnotation(int from,
int to,
AnnotationClass clazz) |
private void |
addSubSpan(Span span) |
Annotations |
annotate(AnnotationClass clazz) |
Annotations |
annotate(int from,
int to,
AnnotationClass clazz)
This will either create or get the annotation of the class annotation
|
private boolean |
contains(int from,
int to) |
private boolean |
equalsRange(int from,
int to) |
Map<AnnotationClass,List<Annotations>> |
getAllAnnotations()
Returns all annotations that are contained in either this subspan or in any of its subannotations
|
private void |
getAllAnnotations(Map<AnnotationClass,List<Annotations>> results) |
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).
|
private void |
getAnnotationClasses(int from,
int to,
Set<AnnotationClass> classes) |
private Annotations |
getBestAnnotation(int from,
int to,
AnnotationClass clazz) |
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
|
private List<Span> |
getRemovableSubSpan() |
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
|
private void |
getTermSpans(String term,
List<Span> spans) |
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
|
private void |
getTokens(List<Span> spans) |
boolean |
hasClass(AnnotationClass clazz)
Returns true if this class
|
private boolean |
intersects(int from,
int to) |
private boolean |
isInside(int from,
int to) |
String |
toString() |
private final Modification modification
private final Map<AnnotationClass,Annotations> annotations
private Span parent
private final int from
private final int to
Span(Modification modification)
private Span(int from, int to, Span parent)
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()
private void addSubSpan(Span span)
private Annotations addAnnotation(int from, int to, AnnotationClass clazz)
private boolean contains(int from, int to)
private boolean isInside(int from, int to)
private boolean intersects(int from, int to)
private boolean equalsRange(int from, int to)
private void getAllAnnotations(Map<AnnotationClass,List<Annotations>> results)
private void getAnnotationClasses(int from, int to, Set<AnnotationClass> classes)
private Annotations getBestAnnotation(int from, int to, AnnotationClass clazz)
Copyright © 2018. All rights reserved.