CleartkExtractor implements
    FeatureExtractor1<FOCUS_T>, FeatureExtractor2<FOCUS_T, FOCUS_T> { public List<Feature> extractWithin(JCas view, FOCUS_T focusAnnotation, Annotation boundsAnnotation) throws CleartkExtractorException { Bounds bounds = new SpanBounds(boundsAnnotation.getBegin(), boundsAnnotation.getEnd()); return this.extract(view, focusAnnotation, bounds); } CleartkExtractor(
      Class<SEARCH_T> annotationClass,
      FeatureExtractor1<SEARCH_T> extractor,
      Context... contexts); @Override List<Feature> extract(JCas view, FOCUS_T focusAnnotation); List<Feature> extractWithin(JCas view, FOCUS_T focusAnnotation, Annotation boundsAnnotation); List<Feature> extractBetween(JCas view, FOCUS_T annotation1, FOCUS_T annotation2); @Override java.util.List<Feature> extract(JCas view, FOCUS_T annotation1, FOCUS_T annotation2);  }
@Test public void testBounds() throws Exception { CleartkExtractor<Chunk, Token> extractor = new CleartkExtractor<Chunk, Token>( Token.class, new CoveredTextExtractor<Token>(), new Preceding(2), new LastCovered(1), new Following(3)); this.tokenBuilder.buildTokens( this.jCas, "She bought milk.\nHe sold oranges.", "She bought milk .\nHe sold oranges ."); Chunk boughMilk = new Chunk(this.jCas, 4, 15); boughMilk.addToIndexes(); Assert.assertEquals("bought milk", boughMilk.getCoveredText()); Chunk soldOranges = new Chunk(this.jCas, 20, 32); soldOranges.addToIndexes(); Assert.assertEquals("sold oranges", soldOranges.getCoveredText()); Collection<Sentence> sentences = JCasUtil.select(jCas, Sentence.class); Assert.assertEquals(2, sentences.size()); Iterator<Sentence> sentIter = sentences.iterator(); Sentence sent1 = sentIter.next(); Sentence sent2 = sentIter.next(); List<Feature> features = extractor.extractWithin(this.jCas, boughMilk, sent1); Assert.assertEquals(6, features.size()); Iterator<Feature> iter = features.iterator(); this.assertFeature("Preceding_0_2_1", "OOB1", iter.next()); this.assertFeature("Preceding_0_2_0", "She", iter.next()); this.assertFeature("LastCovered_0_1_0", "milk", iter.next()); this.assertFeature("Following_0_3_0", ".", iter.next()); this.assertFeature("Following_0_3_1", "OOB1", iter.next()); this.assertFeature("Following_0_3_2", "OOB2", iter.next()); features = extractor.extractWithin(this.jCas, boughMilk, sent2); Assert.assertEquals(6, features.size()); iter = features.iterator(); this.assertFeature("Preceding_0_2_1", "OOB2", iter.next()); this.assertFeature("Preceding_0_2_0", "OOB1", iter.next()); this.assertFeature("LastCovered_0_1_0", "OOB1", iter.next()); this.assertFeature("Following_0_3_0", "OOB1", iter.next()); this.assertFeature("Following_0_3_1", "He", iter.next()); this.assertFeature("Following_0_3_2", "sold", iter.next()); features = extractor.extractWithin(this.jCas, soldOranges, sent2); Assert.assertEquals(6, features.size()); iter = features.iterator(); this.assertFeature("Preceding_0_2_1", "OOB1", iter.next()); this.assertFeature("Preceding_0_2_0", "He", iter.next()); this.assertFeature("LastCovered_0_1_0", "oranges", iter.next()); this.assertFeature("Following_0_3_0", ".", iter.next()); this.assertFeature("Following_0_3_1", "OOB1", iter.next()); this.assertFeature("Following_0_3_2", "OOB2", iter.next()); }