DTAUtils { public static List<List<String>> slidingSymetricWindow(final JCas jcas, final int windowPerSide) { final List<List<String>> list = new ArrayList<>(); final FSIterator<Annotation> sentences = jcas.getAnnotationIndex( Sentence.type).iterator(); while (sentences.hasNext()) { final Sentence sentence = (Sentence) sentences.next(); final List<Token> tokens = JCasUtil.selectCovered(Token.class, sentence); if (tokens.size() < ((windowPerSide * 2) + 1)) continue; for (int i = windowPerSide; i < (tokens.size() - windowPerSide); ++i) { final List<String> inWindow = new ArrayList<>( (windowPerSide * 2) + 1); list.add(inWindow); for (int j = i - windowPerSide; j < (i + windowPerSide + 1); ++j) inWindow.add(tokens.get(j).getCoveredText()); } } return list; }  static CollectionReader getReader(final String inputFile,
			final boolean normalize, final boolean format2017); static boolean hasAnyClassification(final JCas jcas,
			final Class<?>... classes); static List<List<String>> slidingSymetricWindow(final JCas jcas,
			final int windowPerSide);  }
@Test public void testSlidingSymetricWindow() throws Exception { final ArrayList<List<String>> expected = new ArrayList<>(); expected.add(Arrays .asList("Alte deutsche Lieder gesammelt von L. A. v. Arnim und Clemens Brentano ." .split(" "))); for (Version version : Version.values()) { JCas jcas = DTAFileReaderTest.process(true, version); assertEquals(expected, DTAUtils.slidingSymetricWindow(jcas, 6)); assertEquals(4, DTAUtils.slidingSymetricWindow(jcas, 5).size()); } }