### Question:
SentenceFilterAnnotator extends JCasAnnotator_ImplBase { @Override public void process(JCas jCas) throws AnalysisEngineProcessException { StringBuilder sb = new StringBuilder(); for (Sentence s : select(jCas, Sentence.class)) { if (pattern.matcher(s.getCoveredText()).find()) { sb.append(s.getCoveredText().replaceAll("[\t\r\n]", " ") + " "); } } try { int pmId = getHeaderIntDocId(jCas); TextFileWriter.write(new File(outputDir + "/" + pmId + ".tsv"), pmId + "\t" + sb.toString().trim()); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } }  @Override void initialize(UimaContext context); @Override void process(JCas jCas); static final String PARAM_REGEX; }### Answer:
@Test public void test() throws Exception { String testDir = "target/SentenceFilterAnnotatorTest" + currentTimeMillis(); new File(testDir).mkdir(); JCas jCas = getTestCas("I like neurons. I like cells, too. But not cakes."); setDocId(jCas, 17); PipelineBuilder builder = new JcasPipelineBuilder(jCas); builder.add(DotSentenceSplitterAnnotator.class); builder.add( SentenceFilterAnnotator.class, PARAM_REGEX, "\\b((inter)?neurone?s?|cells?)\\b", PARAM_OUTPUT_DIR, testDir); builder.process(); File testFile = new File(testDir + "/17.tsv"); checkFileExists(testFile); String txt = asText(testFile); assertEquals("17\tI like neurons. I like cells, too.\n",txt); }