Class AnnotatedText
- java.lang.Object
-
- com.lucidworks.apollo.common.models.nlp.AnnotatedText
-
public class AnnotatedText extends java.lang.ObjectContainer for text and annotations
-
-
Constructor Summary
Constructors Constructor Description AnnotatedText(java.lang.String text)
-
Method Summary
All 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
-
getText
public java.lang.String getText()
-
addAnnotation
public void addAnnotation(Annotation annotation)
-
getTokens
public java.util.List<Annotation> getTokens()
-
getCoveredTokens
public java.util.List<Annotation> getCoveredTokens(Annotation annotation)
-
getCoveredAnnotations
public 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:
-
getConnectedAnnotations
public 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:
-
getTokensBetweenCharOffsets
public 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:
-
getAnnotationsBetweenCharOffsets
public java.util.Map<java.lang.String,java.util.List<Annotation>> getAnnotationsBetweenCharOffsets(int startTokenOffset, int endTokenOffset, boolean enclosed)
-
getAnnotationsBetweenCharOffsetsByType
public 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:
-
getAnnotationsByType
public java.util.List<Annotation> getAnnotationsByType(java.lang.String type)
-
getCoveredText
public java.lang.String getCoveredText(Annotation annotation)
-
detach
public 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:
-
getAnnotationsAsList
public 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:
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-