Class JCoReTreeMapAnnotationIndex<K extends Comparable<K>,T extends org.apache.uima.jcas.tcas.Annotation>
- java.lang.Object
-
- de.julielab.jcore.utility.index.JCoReMapAnnotationIndex<K,T>
-
- de.julielab.jcore.utility.index.JCoReTreeMapAnnotationIndex<K,T>
-
- Type Parameters:
T- The annotation type the index is over.K- The key type used to index the annotations.
- All Implemented Interfaces:
JCoReAnnotationIndex<T>
public class JCoReTreeMapAnnotationIndex<K extends Comparable<K>,T extends org.apache.uima.jcas.tcas.Annotation> extends JCoReMapAnnotationIndex<K,T>
Use when: You want a fuzzy search on the index keys (please see the note in the next paragraph) or ou specifically need a
TreeMapinstead of aHashMap(if not, refer toJCoReHashMapAnnotationIndex) for some other reason. This only makes sense when you need to impose a specific ordering on the map keys that is useful for one of the searchFuzzy methods (e.g.searchFuzzy(Annotation)). This index allows to match multiple map keys with a single input key, for example by using aComparators.longOverlapComparator()for the TreeMap andTermGenerators.longOffsetTermGenerator()for the keys.PLEASE NOTE: In order to retrieve the correct results, the index TreeSet comparator must be consistent with equals with regards to the index keys (see the JavaDoc to
A trivial subclass ofComparator). That means, it does not need to be consistent with equals for the search key (in fact, not being consistent with the search key is the trick) but results will be undefined if the comparator is not consistent with equals with regards to the keys in the index.JCoReMapAnnotationIndexthat uses a HashMap index.- Author:
- faessler
-
-
Field Summary
-
Fields inherited from class de.julielab.jcore.utility.index.JCoReMapAnnotationIndex
index, indexAnnotationStorageSupplier, indexTermGenerator, searchTermGenerator
-
-
Constructor Summary
Constructors Constructor Description JCoReTreeMapAnnotationIndex(IndexTermGenerator<K> indexTermGenerator, IndexTermGenerator<K> searchTermGenerator)JCoReTreeMapAnnotationIndex(IndexTermGenerator<K> indexTermGenerator, IndexTermGenerator<K> searchTermGenerator, org.apache.uima.jcas.JCas jCas, int type)JCoReTreeMapAnnotationIndex(IndexTermGenerator<K> indexTermGenerator, IndexTermGenerator<K> searchTermGenerator, org.apache.uima.jcas.JCas jCas, org.apache.uima.cas.Type type)JCoReTreeMapAnnotationIndex(Comparator<K> comparator, IndexTermGenerator<K> indexTermGenerator, IndexTermGenerator<K> searchTermGenerator)JCoReTreeMapAnnotationIndex(Comparator<K> comparator, IndexTermGenerator<K> indexTermGenerator, IndexTermGenerator<K> searchTermGenerator, org.apache.uima.jcas.JCas jCas, int type)JCoReTreeMapAnnotationIndex(Comparator<K> comparator, IndexTermGenerator<K> indexTermGenerator, IndexTermGenerator<K> searchTermGenerator, 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 Stream<T>searchFuzzy(Stream<K> searchTerms)Stream<T>searchFuzzy(K key)Returns all annotations associated with an index key that is equal to the given key by means of the comparator given to the TreeMap that is used as an index.Stream<T>searchFuzzy(org.apache.uima.jcas.tcas.Annotation a)
-
-
-
Constructor Detail
-
JCoReTreeMapAnnotationIndex
public JCoReTreeMapAnnotationIndex(IndexTermGenerator<K> indexTermGenerator, IndexTermGenerator<K> searchTermGenerator)
-
JCoReTreeMapAnnotationIndex
public JCoReTreeMapAnnotationIndex(IndexTermGenerator<K> indexTermGenerator, IndexTermGenerator<K> searchTermGenerator, org.apache.uima.jcas.JCas jCas, org.apache.uima.cas.Type type)
-
JCoReTreeMapAnnotationIndex
public JCoReTreeMapAnnotationIndex(IndexTermGenerator<K> indexTermGenerator, IndexTermGenerator<K> searchTermGenerator, org.apache.uima.jcas.JCas jCas, int type)
-
JCoReTreeMapAnnotationIndex
public JCoReTreeMapAnnotationIndex(Comparator<K> comparator, IndexTermGenerator<K> indexTermGenerator, IndexTermGenerator<K> searchTermGenerator)
-
JCoReTreeMapAnnotationIndex
public JCoReTreeMapAnnotationIndex(Comparator<K> comparator, IndexTermGenerator<K> indexTermGenerator, IndexTermGenerator<K> searchTermGenerator, org.apache.uima.jcas.JCas jCas, org.apache.uima.cas.Type type)
-
JCoReTreeMapAnnotationIndex
public JCoReTreeMapAnnotationIndex(Comparator<K> comparator, IndexTermGenerator<K> indexTermGenerator, IndexTermGenerator<K> searchTermGenerator, org.apache.uima.jcas.JCas jCas, int type)
-
-
Method Detail
-
searchFuzzy
public Stream<T> searchFuzzy(K key)
Returns all annotations associated with an index key that is equal to the given key by means of the comparator given to the TreeMap that is used as an index.
If that comparator is consistent with equals (see the JavaDoc to
Comparator) the index will basically return the same results how a HashMap would. However, if the comparator is in general not consistent with equals, but it is for all elements in the index, and the index keys for which holdsindex.comparator().compare(indexkey, key) == 0are located in the index without a gap between them (i.e. no indexkey that would not return 0 on comparison with key), then this method will return all annotations for the matching keys. This can be used to retrieve overlapping annotations, for example.- Parameters:
key- The key to retrieve annotations for.- Returns:
- All annotations associated with an index key where
index.comparator().compare(indexkey, key) == 0.
-
-