### Question:
ChunkAdapter extends JCasAnnotator_ImplBase { @Override public void process(JCas cas) throws AnalysisEngineProcessException { int casEnd = cas.getDocumentText().length() - 1; final List<Chunk> oldChunksToDelete = new LinkedList<Chunk>(); for (Chunk chunk : select(cas, Chunk.class)) { final String coveredText = (chunk.getEnd() > 0) ? chunk.getCoveredText() : cas.getDocumentText().substring(chunk.getBegin(), casEnd); if (coveredText.contains(",")) { oldChunksToDelete.add(chunk); final int originalBegin = chunk.getBegin(); int begin = originalBegin; int end = originalBegin + coveredText.indexOf(",", begin - originalBegin); String[] innterChunksStr = coveredText.split(","); for (String innerChunkStr : innterChunksStr) { Chunk innerChunk = new Chunk(cas); innerChunk.setBegin(begin); innerChunk.setEnd(end); innerChunk.addToIndexes(); begin = end + 1; end = originalBegin + coveredText.indexOf(",", begin - originalBegin); if (end == originalBegin-1 || end > chunk.getEnd()) { end = chunk.getEnd(); } } } } removeChunks(oldChunksToDelete); for (Protein protein : select(cas, Protein.class)) { final String documentText = cas.getDocumentText(); final int proteinEnd = protein.getEnd(); int nextParenthesisPosition = documentText.indexOf("(", proteinEnd); if ((nextParenthesisPosition != -1) && (documentText.substring(proteinEnd, nextParenthesisPosition).matches("\\s*"))) { int nextClosedParenthesisPosition = documentText.indexOf(")", nextParenthesisPosition); if (nextClosedParenthesisPosition != -1) { Annotation innerParenthesisDelimiter = new Annotation(cas, nextParenthesisPosition, nextClosedParenthesisPosition + 1); Collection<Measure> measures = selectCovered(cas, Measure.class, innerParenthesisDelimiter); if (measures.size() > 0) { Collection<Chunk> chunksCoveringProtein = selectCovering(cas, Chunk.class, protein); Collection<Chunk> chunksCoveredByParenthesis = selectCovered(cas, Chunk.class, innerParenthesisDelimiter); int newChunkBegin = Integer.MAX_VALUE; int newChunkEnd = 0; for (Chunk chunkCoveringProtein: chunksCoveringProtein) { int begin = chunkCoveringProtein.getBegin(); if (begin < newChunkBegin) { newChunkBegin = begin; } oldChunksToDelete.add(chunkCoveringProtein); } for (Chunk chunkCoveredByParenthesis: chunksCoveredByParenthesis) { int end = chunkCoveredByParenthesis.getEnd(); if (end > newChunkEnd) { newChunkEnd = end; } oldChunksToDelete.add(chunkCoveredByParenthesis); } Chunk chunkCoveringProteinAndMeasure = new Chunk(cas, newChunkBegin, newChunkEnd); chunkCoveringProteinAndMeasure.addToIndexes(); } } } } removeChunks(oldChunksToDelete); }  @Override void process(JCas cas);  }### Answer:
@Test public void endOfSentenceTest() throws Exception { SimplePipelineBuilder builder = new SimplePipelineBuilder( createReaderDescription(PdfCollectionReader.class, PARAM_INPUT_DIRECTORY, EXTRACT_ROOT + "src/test/resources/test_pdfs/chunk_adapter")); builder.add(getSentenceSplitter()); builder.add(getTokenizer()); builder.add(getPosTagger()); builder.add(getChunker()); builder.add(createEngineDescription(ChunkAdapter.class)); builder.add(ChunkController.class); builder.process(); }