Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntitySearcher.getAnnotations(class) for all ontologies in import closure #1105

Open
jamesamcl opened this issue May 31, 2023 · 1 comment
Open

Comments

@jamesamcl
Copy link

jamesamcl commented May 31, 2023

There is a closed issue #745 which asks about using getAnnotations to retrieve all annotations in the import closure for a given class. The answer before closing says "all methods are overloaded to accept a single ontology or a collection/stream of ontologies" but this does not seem to be the case for getAnnotations.

/**
* Gets the annotations for e. These are deemed to be annotations in annotation assertion axioms
* that have a subject that is an IRI that is equal to the IRI of e, and it also includes
* annotations on the annotation assertion axioms whose annotation property matches
*
* @param e entity
* @param ontology The ontology to be examined for annotation assertion axioms
* @return The annotations that participate directly in an annotation assertion whose subject is
* an IRI corresponding to the IRI of e.
*/
public static Stream<OWLAnnotation> getAnnotations(OWLEntity e, OWLOntology ontology) {
return getAnnotations(e.getIRI(), ontology);
}
/**
* Gets the annotations for e. These are deemed to be annotations in annotation assertion axioms
* that have a subject that is an IRI that is equal to the IRI of e, and it also includes
* annotations on the annotation assertion axioms whose annotation property matches.
*
* @param e entity
* @param ontology The ontology to be examined for annotation assertion axioms
* @return The annotations that participate directly in an annotation assertion whose subject is
* an IRI corresponding to the IRI of e.
*/
public static Stream<OWLAnnotation> getAnnotations(OWLAnnotationSubject e,
OWLOntology ontology) {
return Searcher.annotations(ontology.annotationAssertionAxioms(e));
}
/**
* Obtains the annotations on e where the annotation has the specified annotation property. This
* includes the annotations on annotation assertion axioms with matching annotation property.
*
* @param e entity
* @param ontology The ontology to examine for annotation axioms
* @param annotationProperty The annotation property
* @return A {@code Stream} of {@code OWLAnnotation} objects that have the specified URI.
*/
public static Stream<OWLAnnotation> getAnnotations(OWLEntity e, OWLOntology ontology,
OWLAnnotationProperty annotationProperty) {
return getAnnotations(e.getIRI(), ontology, annotationProperty);
}

There is no overload which accepts a stream of ontologies, as far as I can see.

@ignazio1977
Copy link
Contributor

ignazio1977 commented Jul 13, 2023

There are two. The comment meant there was either a collection or a stream argument; the arguments for these methods are Iterable instances.

/**
 * Obtains the annotations on e where the annotation has the specified annotation property. This
 * includes the annotations on annotation assertion axioms with matching annotation property.
 *
 * @param e entity
 * @param ontologies The ontologies to examine for annotation axioms
 * @param annotationProperty The annotation property
 * @return A set of {@code OWLAnnotation} objects that have the specified URI.
 */
@Nonnull
public static Collection<OWLAnnotation> getAnnotations(@Nonnull OWLAnnotationSubject e,
    @Nonnull Iterable<OWLOntology> ontologies,
    @Nonnull OWLAnnotationProperty annotationProperty) {
    Set<OWLAnnotation> toReturn = new HashSet<>();
    for (OWLOntology o : ontologies) {
        assert o != null;
        toReturn.addAll(getAnnotations(e, o, annotationProperty));
    }
    return toReturn;
}

/**
 * Obtains the annotations on e where the annotation has the specified annotation property. This
 * includes the annotations on annotation assertion axioms with matching annotation property.
 *
 * @param e entity
 * @param ontologies The ontologies to examine for annotation axioms
 * @param annotationProperty The annotation property
 * @return A set of {@code OWLAnnotation} objects that have the specified URI.
 */
@Nonnull
public static Collection<OWLAnnotation> getAnnotations(@Nonnull OWLEntity e,
    @Nonnull Iterable<OWLOntology> ontologies,
    @Nonnull OWLAnnotationProperty annotationProperty) {
    Set<OWLAnnotation> toReturn = new HashSet<>();
    for (OWLOntology o : ontologies) {
        assert o != null;
        toReturn.addAll(getAnnotations(e, o, annotationProperty));
    }
    return toReturn;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants