/** * 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[]> annotationSequences(JCas aJCas) throws FeaturePathException { List<LexicalPhrase[]> phrases = new ArrayList<>(); if (coveringTypeName.isPresent()) { Type coveringType = FeaturePathUtils .getType(aJCas.getTypeSystem(), coveringTypeName.get()); /* iterate over covering annotations */ for (AnnotationFS covering : CasUtil.select(aJCas.getCas(), coveringType)) { phrases.add(annotationSequence(aJCas, Optional.of(covering))); } } else { /* add a single token sequence for the whole document */ phrases.add(annotationSequence(aJCas, Optional.empty())); } return phrases; }
/** * 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[]> annotationSequences(JCas aJCas) throws FeaturePathException { List<LexicalPhrase[]> phrases = new ArrayList<>(); if (coveringTypeName.isPresent()) { Type coveringType = FeaturePathUtils .getType(aJCas.getTypeSystem(), coveringTypeName.get()); /* iterate over covering annotations */ for (AnnotationFS covering : CasUtil.select(aJCas.getCas(), coveringType)) { phrases.add(annotationSequence(aJCas, Optional.of(covering))); } } else { /* add a single token sequence for the whole document */ phrases.add(annotationSequence(aJCas, Optional.empty())); } return phrases; }