Class JCoReOverlapAnnotationIndex<E extends org.apache.uima.jcas.tcas.Annotation>
- java.lang.Object
-
- de.julielab.jcore.utility.index.JCoReOverlapAnnotationIndex<E>
-
- Type Parameters:
E- The annotation type the index should be over.
- All Implemented Interfaces:
JCoReAnnotationIndex<E>
public class JCoReOverlapAnnotationIndex<E extends org.apache.uima.jcas.tcas.Annotation> extends Object implements JCoReAnnotationIndex<E>
Use when: You need to access arbitrary annotations that are in any way overlapped by an input annotation (warning: these quite loose restrictions cause a relatively high search complexity, see below).
Note: If it can be guaranteed that the index elements do not overlap themselves, a
JCoReSetAnnotationIndexwith anComparators.overlapComparator()should be used instead of this class.This index allows to index annotations and then retrieve all those annotations overlapping in any way with another annotation or an arbitrary given pair of begin and end offsets. Each search has the complexity O(n/2) where n is the size of the index. This rather bad complexity class stems from the fast that this class handles the general case of overlapping: Suppose we search for an annotation a that happens to be in the middle of the document. The only thing we know is that we can rule out all index elements then begin after a and those that end before a. All other annotations might still overlap a. We have to compare to all index elements from the beginning (or the end) up to the point where we know that we can omit the rest of the index elements. Those are - in the case a lies in the middle of the index elements - n/2.
- Author:
- faessler
-
-
Constructor Summary
Constructors Constructor Description JCoReOverlapAnnotationIndex()JCoReOverlapAnnotationIndex(org.apache.uima.jcas.JCas jcas, int type)JCoReOverlapAnnotationIndex(org.apache.uima.jcas.JCas jcas, org.apache.uima.cas.Type type)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(E a)voidfreeze()voidindex(E annotation)voidindex(org.apache.uima.jcas.JCas jCas, int type)Indexes the whole contents of the CAS annotation index of type type.voidindex(org.apache.uima.jcas.JCas jCas, org.apache.uima.cas.Type type)Indexes the whole contents of the CAS annotation index of type type.voidmelt()Un-freeze the index to allow new elements to be added.<T extends org.apache.uima.jcas.tcas.Annotation>
Stream<E>search(T a)Returns all annotation in the index overlapping in any way with a (embedded, covering, partial overlappings).
-
-
-
Constructor Detail
-
JCoReOverlapAnnotationIndex
public JCoReOverlapAnnotationIndex()
-
JCoReOverlapAnnotationIndex
public JCoReOverlapAnnotationIndex(org.apache.uima.jcas.JCas jcas, int type)
-
JCoReOverlapAnnotationIndex
public JCoReOverlapAnnotationIndex(org.apache.uima.jcas.JCas jcas, org.apache.uima.cas.Type type)
-
-
Method Detail
-
index
public void index(org.apache.uima.jcas.JCas jCas, int type)Indexes the whole contents of the CAS annotation index of type type. For each annotation, the#indexTermGeneratoris used to create terms with which the annotation will be associated in the index and can be retrieved by asearchmethod.- Specified by:
indexin interfaceJCoReAnnotationIndex<E extends org.apache.uima.jcas.tcas.Annotation>- Parameters:
jCas- A CAS instance.type- The annotation type to index.
-
index
public void index(org.apache.uima.jcas.JCas jCas, org.apache.uima.cas.Type type)Indexes the whole contents of the CAS annotation index of type type. For each annotation, the#indexTermGeneratoris used to create terms with which the annotation will be associated in the index and can be retrieved by asearchmethod.- Specified by:
indexin interfaceJCoReAnnotationIndex<E extends org.apache.uima.jcas.tcas.Annotation>- Parameters:
jCas- A CAS instance.type- The annotation type to index.
-
index
public void index(E annotation)
- Specified by:
indexin interfaceJCoReAnnotationIndex<E extends org.apache.uima.jcas.tcas.Annotation>
-
freeze
public void freeze()
-
search
public <T extends org.apache.uima.jcas.tcas.Annotation> Stream<E> search(T a)
Returns all annotation in the index overlapping in any way with a (embedded, covering, partial overlappings). The resulting list is either sorted by begin or end offset. It is not easily predictable which case it is (could be added as a return value if that would be useful in any way).- Parameters:
a- The annotation to retrieve overlapping annotations from the index for.- Returns:
- All annotations in the index overlapping a.
-
melt
public void melt()
Un-freeze the index to allow new elements to be added.
-
add
public void add(E a)
- Specified by:
addin interfaceJCoReAnnotationIndex<E extends org.apache.uima.jcas.tcas.Annotation>
-
-