Class AnnotatedText
- java.lang.Object
- 
- com.lucidworks.apollo.common.models.nlp.AnnotatedText
 
- 
 public class AnnotatedText extends java.lang.ObjectContainer for text and annotations
- 
- 
Constructor SummaryConstructors Constructor Description AnnotatedText(java.lang.String text)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAnnotation(Annotation annotation)AnnotatedTextdetach(Annotation inputAnnotation)Detach text and annotations covered by inputAnnotation into it's own AnnotatedText instance with annotation offsets correctly set relative to detached textbooleanequals(java.lang.Object obj)java.util.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.java.util.Map<java.lang.String,java.util.List<Annotation>>getAnnotationsBetweenCharOffsets(int startTokenOffset, int endTokenOffset, boolean enclosed)java.util.List<Annotation>getAnnotationsBetweenCharOffsetsByType(int startTokenOffset, int endTokenOffset, java.lang.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 rangesjava.util.List<Annotation>getAnnotationsByType(java.lang.String type)java.util.Map<java.lang.String,java.util.List<Annotation>>getConnectedAnnotations(Annotation annotation)Get all annotations connected to the input annotation's offsets.java.util.Map<java.lang.String,java.util.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 sentencejava.lang.StringgetCoveredText(Annotation annotation)java.util.List<Annotation>getCoveredTokens(Annotation annotation)java.lang.StringgetText()java.util.List<Annotation>getTokens()java.util.List<Annotation>getTokensBetweenCharOffsets(int startCharOffset, int endCharOffset)Get all tokens that are completely enclosed by start / end character offsetsinthashCode()
 
- 
- 
- 
Method Detail- 
getTextpublic java.lang.String getText() 
 - 
addAnnotationpublic void addAnnotation(Annotation annotation) 
 - 
getTokenspublic java.util.List<Annotation> getTokens() 
 - 
getCoveredTokenspublic java.util.List<Annotation> getCoveredTokens(Annotation annotation) 
 - 
getCoveredAnnotationspublic java.util.Map<java.lang.String,java.util.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- Parameters:
- annotation-
- Returns:
 
 - 
getConnectedAnnotationspublic java.util.Map<java.lang.String,java.util.List<Annotation>> getConnectedAnnotations(Annotation annotation) Get all annotations connected to the input annotation's offsets. For example, pass in a token annotation to retrieve all annotations that include that token.- Parameters:
- annotation-
- Returns:
 
 - 
getTokensBetweenCharOffsetspublic java.util.List<Annotation> getTokensBetweenCharOffsets(int startCharOffset, int endCharOffset) Get all tokens that are completely enclosed by start / end character offsets- Parameters:
- startCharOffset-
- endCharOffset-
- Returns:
 
 - 
getAnnotationsBetweenCharOffsetspublic java.util.Map<java.lang.String,java.util.List<Annotation>> getAnnotationsBetweenCharOffsets(int startTokenOffset, int endTokenOffset, boolean enclosed) 
 - 
getAnnotationsBetweenCharOffsetsByTypepublic java.util.List<Annotation> getAnnotationsBetweenCharOffsetsByType(int startTokenOffset, int endTokenOffset, java.lang.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- Parameters:
- startTokenOffset-
- endTokenOffset-
- type-
- enclosed-
- Returns:
 
 - 
getAnnotationsByTypepublic java.util.List<Annotation> getAnnotationsByType(java.lang.String type) 
 - 
getCoveredTextpublic java.lang.String getCoveredText(Annotation annotation) 
 - 
detachpublic 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- Parameters:
- inputAnnotation-
- Returns:
 
 - 
getAnnotationsAsListpublic java.util.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.- Returns:
 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- java.lang.Object
 
 - 
equalspublic boolean equals(java.lang.Object obj) - Overrides:
- equalsin class- java.lang.Object
 
 
- 
 
-