/** * Extract a list of {@link LexicalPhrase} arrays from the {@link JCas}. * <p> * If {@link #coveringTypeName} is set, a dedicated array for each covering annotation is * extracted. Otherwise, the result contains only one element. * * @param aJCas * a {@link JCas} * @return a list of {@link LexicalPhrase} arrays * @throws FeaturePathException * if there was a problem creating the feature path. */ private List<LexicalPhrase[]> characterSequences(JCas aJCas) throws FeaturePathException { if (coveringTypeName.isPresent()) { Type coveringType = FeaturePathUtils .getType(aJCas.getTypeSystem(), coveringTypeName.get()); return CasUtil.select(aJCas.getCas(), coveringType).stream() .map(covering -> characterSequence(aJCas, covering.getCoveredText(), covering.getBegin())) .collect(Collectors.toList()); } else { return Collections.singletonList(characterSequence(aJCas, aJCas.getDocumentText(), 0)); } }
/** * Extract a list of {@link LexicalPhrase} arrays from the {@link JCas}. * <p> * If {@link #coveringTypeName} is set, a dedicated array for each covering annotation is * extracted. Otherwise, the result contains only one element. * * @param aJCas * a {@link JCas} * @return a list of {@link LexicalPhrase} arrays * @throws FeaturePathException * if there was a problem creating the feature path. */ private List<LexicalPhrase[]> characterSequences(JCas aJCas) throws FeaturePathException { if (coveringTypeName.isPresent()) { Type coveringType = FeaturePathUtils .getType(aJCas.getTypeSystem(), coveringTypeName.get()); return CasUtil.select(aJCas.getCas(), coveringType).stream() .map(covering -> characterSequence(aJCas, covering.getCoveredText(), covering.getBegin())) .collect(Collectors.toList()); } else { return Collections.singletonList(characterSequence(aJCas, aJCas.getDocumentText(), 0)); } }