Package com.yahoo.text.interpretation
Class Span
java.lang.Object
com.yahoo.text.interpretation.Span
Span is a description of a part of a text, modeled as a tree.
A span is defined by the range (from,to) and by a set of annotations on that range. It also contains a set
of child nodes that all have the restriction
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.
- Author:
- Arne Bergene Fossaa
-
Method Summary
Modifier and TypeMethodDescriptionannotate
(int from, int to, AnnotationClass clazz) This will either create or get the annotation of the class annotationannotate
(AnnotationClass clazz) Returns all annotations that are contained in either this subspan or in any of its subannotationsgetAnnotation
(int from, int to, AnnotationClass clazz) Returns the annotations with a specific class for the area defined by (from,to).getAnnotation
(AnnotationClass clazz) Returns the annotations with a specific class for the area defined by this spanReturns all AnnotationClasses that are defined for this span and any of its superspans.getClasses
(int from, int to) Returns all AnnotationClasses that are defined for the range (from,to).int
getFrom()
hackReturns all spans that are directly childrens of this span.getTermSpans
(String term) Returns all spans, either this or any of the spans that are inherits this span that match the given termgetText()
Returns the text that this spans isint
getTo()
hackReturns an unmodifiable list of all spans below this span that is a leaf nodeboolean
hasClass
(AnnotationClass clazz) Returns true if this classtoString()
-
Method Details
-
getText
Returns the text that this spans is -
toString
-
annotate
-
annotate
This will either create or get the annotation of the class annotation -
getAllAnnotations
Returns all annotations that are contained in either this subspan or in any of its subannotations -
getTermSpans
Returns all spans, either this or any of the spans that are inherits this span that match the given term -
getAnnotation
Returns the annotations with a specific class for the area defined by this spanThis 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.
-
getAnnotation
Returns the annotations with a specific class for the area defined by (from,to). 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.- Throws:
RuntimeException
- if (from,to) is not contained in the span
-
getClasses
Returns all AnnotationClasses that are defined for this span and any of its superspans. -
getClasses
Returns all AnnotationClasses that are defined for the range (from,to).- Throws:
RuntimeException
- if (from, to) is not contained in the span
-
getTokens
Returns an unmodifiable list of all spans below this span that is a leaf node -
hasClass
Returns true if this class -
getSubSpans
Returns all spans that are directly childrens of this span. If the span is a leaf, the empty list will be returned. The list is unmodifable. -
getFrom
public int getFrom()hack -
getTo
public int getTo()hack
-