private void checkLemma(String[] expected, Collection<Lemma> actual) { int i = 0; for (Lemma lemmaAnnotation : actual) { assertEquals("In position " + i, expected[i], lemmaAnnotation.getValue()); i++; } }
private static Collection<String> getTokensFromAnnotation( AnnotationFS annotation, boolean useLemma, int minTokenLength) { Collection<String> tokens; if (useLemma) { tokens = new ArrayList<>(); /* concatenate multiple lemmas: */ // selectCovered(Lemma.class, annotation).stream() // .map(lemma -> lemma.getValue()) // .filter(lemma -> lemma.length() >= minTokenLength) // .reduce((l1, l2) -> l1 + "_" + l2) // .ifPresent(token -> tokens.add(token)); for (Lemma lemma : selectCovered(Lemma.class, annotation)) { String text = lemma.getValue(); if (text.length() >= minTokenLength) { tokens.add(text); } } } else { tokens = new ArrayList<>(1); String text = annotation.getCoveredText(); if (text.length() >= minTokenLength) { tokens.add(text); } } return tokens; }