CasFilter_ImplBase extends JCasMultiplier_ImplBase { public static AnalysisEngineDescription createAggregateBuilderDescription( AnalysisEngineDescription... aEngines) throws ResourceInitializationException { AggregateBuilder aggregateBuilder = new AggregateBuilder(); aggregateBuilder.setFlowControllerDescription(FlowControllerFactory .createFlowControllerDescription(FixedFlowController.class, FixedFlowController.PARAM_ACTION_AFTER_CAS_MULTIPLIER, "drop")); for (AnalysisEngineDescription aEngine : aEngines) { aggregateBuilder.add(aEngine); } return aggregateBuilder.createAggregateDescription(); }  @Override boolean hasNext(); @Override AbstractCas next(); @Override void process(JCas aJCas); static AnalysisEngineDescription createAggregateBuilderDescription(
            AnalysisEngineDescription... aEngines); static AnalysisEngineDescription createAggregateBuilderDescription(
            List<AnalysisEngineDescription> aEngines);  }
@Test public void testAnnotationFilterPass() throws UIMAException, IOException { File tmpFile = new File(testContext.getTestOutputFolder(), "output.dump"); String input = "test"; String expectedFirstLine = "======== CAS 0 begin =================================="; CollectionReaderDescription reader = createReaderDescription( StringReader.class, StringReader.PARAM_DOCUMENT_TEXT, input, StringReader.PARAM_LANGUAGE, "en"); AnalysisEngineDescription filter = createEngineDescription(AnnotationBasedFilter.class); AnalysisEngineDescription annotator = createEngineDescription(TestAnnotator.class); AnalysisEngineDescription writer = createEngineDescription( CasDumpWriter.class, CasDumpWriter.PARAM_TARGET_LOCATION, tmpFile); AnalysisEngineDescription aggregator = CasFilter_ImplBase .createAggregateBuilderDescription(filter, writer); SimplePipeline.runPipeline(reader, annotator, aggregator); List<String> output = FileUtils.readLines(tmpFile); assertEquals(expectedFirstLine, output.get(0)); assertEquals(input, output.get(13)); assertEquals("Sentence", output.get(15)); }
@Test public void testAnnotationFilterRemove() throws UIMAException, IOException { File tmpFile = new File(testContext.getTestOutputFolder(), "output.dump"); String input = ""; CollectionReaderDescription reader = createReaderDescription(StringReader.class, StringReader.PARAM_DOCUMENT_TEXT, input, StringReader.PARAM_LANGUAGE, "en"); AnalysisEngineDescription filter = createEngineDescription(AnnotationBasedFilter.class); AnalysisEngineDescription annotator = createEngineDescription(TestAnnotator.class); AnalysisEngineDescription writer = createEngineDescription(CasDumpWriter.class, CasDumpWriter.PARAM_TARGET_LOCATION, tmpFile); AnalysisEngineDescription aggregator = CasFilter_ImplBase .createAggregateBuilderDescription(filter, writer); SimplePipeline.runPipeline(reader, annotator, aggregator); assertTrue(FileUtils.readFileToString(tmpFile).isEmpty()); }
@Test public void testEmptyDocumentFilterRemove() throws UIMAException, IOException { File tmpFile = new File(testContext.getTestOutputFolder(), "output.dump"); String input = ""; CollectionReaderDescription reader = createReaderDescription(StringReader.class, StringReader.PARAM_DOCUMENT_TEXT, input, StringReader.PARAM_LANGUAGE, "en"); AnalysisEngineDescription filter = createEngineDescription(EmptyDocumentFilter.class); AnalysisEngineDescription writer = createEngineDescription(CasDumpWriter.class, CasDumpWriter.PARAM_TARGET_LOCATION, tmpFile); AnalysisEngineDescription aggregator = CasFilter_ImplBase .createAggregateBuilderDescription(filter, writer); SimplePipeline.runPipeline(reader, aggregator); assertTrue(FileUtils.readFileToString(tmpFile).isEmpty()); }
@Test public void testEmptyDocumentFilterPass() throws UIMAException, IOException { File tmpFile = new File(testContext.getTestOutputFolder(), "output.dump"); String input = "test"; CollectionReaderDescription reader = createReaderDescription(StringReader.class, StringReader.PARAM_DOCUMENT_TEXT, input, StringReader.PARAM_LANGUAGE, "en"); AnalysisEngineDescription filter = createEngineDescription(EmptyDocumentFilter.class); AnalysisEngineDescription writer = createEngineDescription(CasDumpWriter.class, CasDumpWriter.PARAM_TARGET_LOCATION, tmpFile); AnalysisEngineDescription aggregator = CasFilter_ImplBase .createAggregateBuilderDescription(filter, writer); SimplePipeline.runPipeline(reader, aggregator); assertFalse(FileUtils.readFileToString(tmpFile).isEmpty()); }
@Test public void testLanguageFilterPass() throws UIMAException, IOException { File tmpFile = new File(testContext.getTestOutputFolder(), "output.dump"); String input = "test"; CollectionReaderDescription reader = createReaderDescription(StringReader.class, StringReader.PARAM_DOCUMENT_TEXT, input, StringReader.PARAM_LANGUAGE, "en"); AnalysisEngineDescription filter = createEngineDescription(LanguageFilter.class, LanguageFilter.PARAM_REQUIRED_LANGUAGES, new String[] { "de", "en" }); AnalysisEngineDescription writer = createEngineDescription(CasDumpWriter.class, CasDumpWriter.PARAM_TARGET_LOCATION, tmpFile); AnalysisEngineDescription aggregator = CasFilter_ImplBase .createAggregateBuilderDescription(filter, writer); SimplePipeline.runPipeline(reader, aggregator); assertFalse(FileUtils.readFileToString(tmpFile).isEmpty()); }
@Test public void testLanguageFilterRemove() throws UIMAException, IOException { File tmpFile = new File(testContext.getTestOutputFolder(), "output.dump"); String input = "test"; CollectionReaderDescription reader = createReaderDescription(StringReader.class, StringReader.PARAM_DOCUMENT_TEXT, input, StringReader.PARAM_LANGUAGE, "ch"); AnalysisEngineDescription filter = createEngineDescription(LanguageFilter.class, LanguageFilter.PARAM_REQUIRED_LANGUAGES, new String[] { "de", "en" }); AnalysisEngineDescription writer = createEngineDescription(CasDumpWriter.class, CasDumpWriter.PARAM_TARGET_LOCATION, tmpFile); AnalysisEngineDescription aggregator = CasFilter_ImplBase .createAggregateBuilderDescription(filter, writer); SimplePipeline.runPipeline(reader, aggregator); assertTrue(FileUtils.readFileToString(tmpFile).isEmpty()); }