@Test public void testStringIndex() throws Exception { JCas cas = JCasFactory.createJCas("de.julielab.jcore.types.jcore-all-types"); cas.setDocumentText("token1 token2 token3 token4"); Token t1 = new Token(cas, 0, 6); Token t2 = new Token(cas, 7, 13); Token t3 = new Token(cas, 14, 20); Token t4 = new Token(cas, 21, 27); t1.addToIndexes(); t2.addToIndexes(); t3.addToIndexes(); t4.addToIndexes(); Entity e1 = new Entity(cas, 7, 13); JCoReTreeMapAnnotationIndex<Long, Token> index = new JCoReTreeMapAnnotationIndex<>( Comparators.longOverlapComparator(), TermGenerators.longOffsetTermGenerator(), TermGenerators.longOffsetTermGenerator()); index.index(cas, Token.type); Set<Token> search = index.search(e1).collect(Collectors.toSet()); assertEquals(1, search.size()); assertEquals("token2", search.iterator().next().getCoveredText()); search = index.searchFuzzy((0l << 32) | 27).collect(Collectors.toSet()); assertEquals(4, search.size()); search = index.searchFuzzy((10l << 32) | 17).collect(Collectors.toSet()); assertEquals(2, search.size()); }
@SuppressWarnings("unchecked") public Stream<T> searchFuzzy(Annotation a) { Object o = searchTermGenerator.generateIndexTerms(a); if (o instanceof Stream) { Stream<K> searchTerms = (Stream<K>) o; try { return searchFuzzy(searchTerms); } finally { searchTerms.close(); } } else { return searchFuzzy((K) o); } }
JCoReTreeMapAnnotationIndex extends JCoReMapAnnotationIndex<K, T> { @SuppressWarnings("unchecked") public Stream<T> searchFuzzy(Annotation a) { Object o = searchTermGenerator.generateIndexTerms(a); if (o instanceof Stream) { Stream<K> searchTerms = (Stream<K>) o; try { return searchFuzzy(searchTerms); } finally { searchTerms.close(); } } else { return searchFuzzy((K) o); } } }
JCoReTreeMapAnnotationIndex extends JCoReMapAnnotationIndex<K, T> { @SuppressWarnings("unchecked") public Stream<T> searchFuzzy(Annotation a) { Object o = searchTermGenerator.generateIndexTerms(a); if (o instanceof Stream) { Stream<K> searchTerms = (Stream<K>) o; try { return searchFuzzy(searchTerms); } finally { searchTerms.close(); } } else { return searchFuzzy((K) o); } } JCoReTreeMapAnnotationIndex(IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator);  JCoReTreeMapAnnotationIndex(IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator, JCas jCas, Type type);  JCoReTreeMapAnnotationIndex(IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator, JCas jCas, int type);  JCoReTreeMapAnnotationIndex(Comparator<K> comparator, IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator);  JCoReTreeMapAnnotationIndex(Comparator<K> comparator, IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator, JCas jCas, Type type);  JCoReTreeMapAnnotationIndex(Comparator<K> comparator, IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator, JCas jCas, int type); }
JCoReTreeMapAnnotationIndex extends JCoReMapAnnotationIndex<K, T> { @SuppressWarnings("unchecked") public Stream<T> searchFuzzy(Annotation a) { Object o = searchTermGenerator.generateIndexTerms(a); if (o instanceof Stream) { Stream<K> searchTerms = (Stream<K>) o; try { return searchFuzzy(searchTerms); } finally { searchTerms.close(); } } else { return searchFuzzy((K) o); } } JCoReTreeMapAnnotationIndex(IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator);  JCoReTreeMapAnnotationIndex(IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator, JCas jCas, Type type);  JCoReTreeMapAnnotationIndex(IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator, JCas jCas, int type);  JCoReTreeMapAnnotationIndex(Comparator<K> comparator, IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator);  JCoReTreeMapAnnotationIndex(Comparator<K> comparator, IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator, JCas jCas, Type type);  JCoReTreeMapAnnotationIndex(Comparator<K> comparator, IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator, JCas jCas, int type); @SuppressWarnings("unchecked") Stream<T> searchFuzzy(Annotation a); Stream<T> searchFuzzy(Stream<K> searchTerms); Stream<T> searchFuzzy(K key); }
JCoReTreeMapAnnotationIndex extends JCoReMapAnnotationIndex<K, T> { @SuppressWarnings("unchecked") public Stream<T> searchFuzzy(Annotation a) { Object o = searchTermGenerator.generateIndexTerms(a); if (o instanceof Stream) { Stream<K> searchTerms = (Stream<K>) o; try { return searchFuzzy(searchTerms); } finally { searchTerms.close(); } } else { return searchFuzzy((K) o); } } JCoReTreeMapAnnotationIndex(IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator);  JCoReTreeMapAnnotationIndex(IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator, JCas jCas, Type type);  JCoReTreeMapAnnotationIndex(IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator, JCas jCas, int type);  JCoReTreeMapAnnotationIndex(Comparator<K> comparator, IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator);  JCoReTreeMapAnnotationIndex(Comparator<K> comparator, IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator, JCas jCas, Type type);  JCoReTreeMapAnnotationIndex(Comparator<K> comparator, IndexTermGenerator<K> indexTermGenerator,
			IndexTermGenerator<K> searchTermGenerator, JCas jCas, int type); @SuppressWarnings("unchecked") Stream<T> searchFuzzy(Annotation a); Stream<T> searchFuzzy(Stream<K> searchTerms); Stream<T> searchFuzzy(K key);  }