/** * Convert an {@link ArrayFS} to a {@link Collection}. * * @param aArray * the array to convert. * @return a new collection containing the same feature structures as the provided array. * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a> */ public static Collection<FeatureStructure> create(ArrayFS aArray) { return create(aArray, (Type) null); }
/** * Convenience method to iterator over all feature structures of a given type. * * @param array * features structure array. * @param type * the type. * @return A collection of the selected type. * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a> */ public static Collection<FeatureStructure> selectFS(ArrayFS array, Type type) { return FSCollectionFactory.create(array, type); }
/** * Convenience method to iterator over all feature structures of a given type. * * @param cas * the CAS containing the type system. * @param type * the type. * @return A collection of the selected type. * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a> */ public static Collection<FeatureStructure> selectFS(final CAS cas, final Type type) { return FSCollectionFactory.create(cas, type); }
public static Collection<TOP> create(FSList aList) { return create(aList, (Type) null); }
/** * * Create a Split[] array from a FSArray * * @param splitsFSArray * FSArray containing the splits * @return The array containing the splits from FSArray */ private Split[] createSplitsFromFSArray(final FSArray splitsFSArray) { final Collection<Split> splitsCollection = FSCollectionFactory.create(splitsFSArray, Split.class); return splitsCollection.toArray(new Split[splitsCollection.size()]); } }
/** * * Create a Split[] array from a FSArray * * @param splitsFSArray * FSArray containing the splits * @return The array containing the splits from FSArray */ private Split[] createSplitsFromFSArray(final FSArray splitsFSArray) { final Collection<Split> splitsCollection = FSCollectionFactory.create(splitsFSArray, Split.class); return splitsCollection.toArray(new Split[splitsCollection.size()]); } }
@Override @SuppressWarnings("unchecked") protected Collection<E> getCollection(FeatureStructure anno) { ArrayFS fsArray = (ArrayFS) anno.getFeatureValue(feature); if (fsArray == null) { return null; } return (Collection<E>) FSCollectionFactory.create(fsArray); } }
public static Collection<CandidateAnswerOccurrence> getCandidateAnswerOccurrences( CandidateAnswerVariant cav) { return FSCollectionFactory.create(cav.getOccurrences(), CandidateAnswerOccurrence.class); }
public static Collection<ConceptType> getConceptTypes(Concept concept) { return FSCollectionFactory.create(concept.getTypes(), ConceptType.class); }
public static Collection<CandidateAnswerVariant> getCandidateAnswerVariants(Answer answer) { return FSCollectionFactory.create(answer.getVariants(), CandidateAnswerVariant.class); }
public static Collection<ConceptMention> getConceptMentions(Concept concept) { return FSCollectionFactory.create(concept.getMentions(), ConceptMention.class); }
public static Collection<String> getConceptUris(Concept concept) { return FSCollectionFactory.create(concept.getUris()); }
public static Collection<String> getConceptIds(Concept concept) { return FSCollectionFactory.create(concept.getIds()); }
public static Collection<String> getCandidateAnswerVariantNames(CandidateAnswerVariant cav) { return FSCollectionFactory.create(cav.getNames()); }
@Deprecated public static AbstractQuery getAbstractQueriesCombined(JCas jcas) { List<QueryConcept> conceptsCombined = getAbstractQueries(jcas).stream() .flatMap(a -> FSCollectionFactory.create(a.getConcepts(), QueryConcept.class).stream()) .collect(toList()); return TypeFactory.createAbstractQuery(jcas, conceptsCombined); }
public static List<FeatureStructure> toList(Feature targetFeat, FeatureStructure fs) { if (fs == null) { return null; } // TODO handle lists if (targetFeat.getRange().isArray()) { return new ArrayList<FeatureStructure>( FSCollectionFactory.create((ArrayFS) fs)); } else { throw new UnsupportedOperationException(); } }
/** * Get an iterator over the given feature structure type. * * @param <T> * the JCas type. * @param jCas * a JCas. * @param type * a type. * @return a return value. * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a> */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static <T extends TOP> Iterator<T> iterator(JCas jCas, Class<T> type) { return (Iterator) FSCollectionFactory.create(jCas.getCas(), getType(jCas, type)).iterator(); }
/** * Fetch all annotations of the given type or its sub-types from the given FS array. * * @param <T> * the JCas type. * @param aArray * the FS array * @param aType * the JCas wrapper class. * @return a new collection of all feature structures of the given type. */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static <T extends TOP> Collection<T> create(ArrayFS aArray, Class<T> aType) { return (Collection) create(aArray, CasUtil.getType(aArray.getCAS(), aType)); }
/** * Fetch all annotations of the given type or its sub-types from the given FS list. * * @param <T> * the JCas type. * @param aList * the FS list * @param aType * the JCas wrapper class. * @return a new collection of all feature structures of the given type. */ @SuppressWarnings("unchecked") public static <T extends TOP> Collection<T> create(FSList aList, Class<T> aType) { return (Collection<T>) create(aList, CasUtil.getType(aList.getCAS(), aType)); }
/** * Convenience method to iterator over all annotations of a given type. * * @param cas * the CAS containing the type system. * @param type * the type. * @return A collection of the selected type. * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a> */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static Collection<AnnotationFS> select(final CAS cas, final Type type) { if (!cas.getTypeSystem().subsumes(cas.getAnnotationType(), type)) { throw new IllegalArgumentException("Type [" + type.getName() + "] is not an annotation type"); } return (Collection) FSCollectionFactory.create(cas.getAnnotationIndex(type)); }