BaleenTextAwareAnnotator extends BaleenAnnotator { protected List<TextBlock> getTextBlocks(final JCas jCas) { if (!wholeDocumentAsText) { final Collection<Text> collection = JCasUtil.select(jCas, Text.class); if (!collection.isEmpty()) { return JCasUtil.select(jCas, Text.class).stream() .map(t -> new TextBlock(jCas, t)) .collect(Collectors.toList()); } } return Collections.singletonList(new TextBlock(jCas)); }   static final String TEXT_BLOCK_SEPARATOR; static final String PARAM_WHOLE_DOCUMENT; }
@Test public void testGetTextBlockForTextBlocks() { final FakeTextAwareAnnotator annotator = createAnnotator(false); final List<TextBlock> list = annotator.getTextBlocks(textJCas); assertEquals(2, list.size()); assertEquals("text", list.get(0).getCoveredText()); assertEquals("more text", list.get(1).getCoveredText()); }
@Test public void testGetTextBlockForEntireDoc() { final FakeTextAwareAnnotator annotator = createAnnotator(false); final List<TextBlock> list = annotator.getTextBlocks(noTextJCas); assertEquals(1, list.size()); assertEquals("This is text and more text", list.get(0).getCoveredText()); }
@Test public void testGetTextBlockWhenHasBlocksButWholeDocParamIsSet() { final FakeTextAwareAnnotator annotator = createAnnotator(true); final List<TextBlock> list = annotator.getTextBlocks(textJCas); assertEquals(1, list.size()); assertEquals("This is text and more text", list.get(0).getCoveredText()); }