SentencePipeline extends BasicAnnotatorService { public SentencePipeline(TextAnnotationBuilder textAnnotationBuilder, Map<String, Annotator> viewProviders, ResourceManager rm) throws AnnotatorException { super(textAnnotationBuilder, viewProviders, rm); } SentencePipeline(TextAnnotationBuilder textAnnotationBuilder,
            Map<String, Annotator> viewProviders, ResourceManager rm); @Override boolean addView(TextAnnotation textAnnotation, String viewName); void processBySentence(Annotator annotator, TextAnnotation textAnnotation);  }
@Test public void testSentencePipeline() { String[] viewsToAdd = new String[] {}; TextAnnotation ta = DummyTextAnnotationGenerator.generateAnnotatedTextAnnotation(viewsToAdd, false, 3); String[] viewsToAnnotate = {ViewNames.POS, ViewNames.NER_CONLL, ViewNames.PARSE_STANFORD}; Set<String> viewSet = new HashSet<>(); for (String viewName : viewsToAnnotate) viewSet.add(viewName); try { sentenceProcessor.addViewsAndCache(ta, viewSet, false); } catch (AnnotatorException e) { e.printStackTrace(); fail(e.getMessage()); } assertTrue(ta.hasView(ViewNames.POS)); assertEquals(29, ta.getView(ViewNames.POS).getConstituents().size()); assertTrue(ta.hasView(ViewNames.NER_CONLL)); assertEquals(1, ta.getView(ViewNames.NER_CONLL).getConstituents().size()); assertTrue(ta.hasView(ViewNames.PARSE_STANFORD)); assertEquals(84, ta.getView(ViewNames.PARSE_STANFORD).getConstituents().size()); TextAnnotation normalTa = DummyTextAnnotationGenerator.generateAnnotatedTextAnnotation(viewsToAdd, false, 3); try { normalProcessor.addViewsAndCache(normalTa, viewSet, false); } catch (AnnotatorException e) { e.printStackTrace(); fail(e.getMessage()); } assertTrue(normalTa.hasView(ViewNames.POS)); assertEquals(29, normalTa.getView(ViewNames.POS).getConstituents().size()); assertTrue(ta.hasView(ViewNames.NER_CONLL)); assertEquals(1, ta.getView(ViewNames.NER_CONLL).getConstituents().size()); assertTrue(ta.hasView(ViewNames.PARSE_STANFORD)); assertEquals(84, ta.getView(ViewNames.PARSE_STANFORD).getConstituents().size()); List<Constituent> sentPos = ta.getView(ViewNames.POS).getConstituents(); List<Constituent> normalPos = normalTa.getView(ViewNames.POS).getConstituents(); for (int i = 0; i < sentPos.size(); ++i) assertEquals(normalPos.get(i), sentPos.get(i)); assertTrue(IOUtils.exists(CACHE_DIR_SENTENCE)); }