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 ignores annotations from imports #745

Closed
reality opened this issue Mar 27, 2018 · 2 comments
Closed

EntitySearcher ignores annotations from imports #745

reality opened this issue Mar 27, 2018 · 2 comments
Labels

Comments

@reality
Copy link
Contributor

reality commented Mar 27, 2018

The EntitySearcher interface seems to have no way to obtain annotations from classes residing in imported ontologies. The following code will not return any annotations from imported ontologies:

EntitySearcher.getAnnotations(oClass, ontology).each { annotation ->
  println annotation
}

You can obtain them using the annotationAssertionAxioms stream in OWLOntology:

ontology.annotationAssertionAxioms(oClass.getIRI(), Imports.INCLUDED).each {
  println it
}

Would it be possible to add the same Imports enum flag to the EntitySearcher annotation methods? I notice that some of the methods already have this functionality, e.g. getAxiomsIgnoreAnnotations

Thank you!

@ignazio1977
Copy link
Contributor

To get the annotations from imported ontologies, pass the imports closure in the method. All methods are overloaded to accept a single ontology or a collection/stream of ontologies (depending whether you're using version 4 or 5).

@jamesamcl
Copy link

To get the annotations from imported ontologies, pass the imports closure in the method. All methods are overloaded to accept a single ontology or a collection/stream of ontologies (depending whether you're using version 4 or 5).

This seems true for getAnnotationObjects but not getAnnotations?

I don't see any overload that takes a collection/stream of ontologies:

/**
* 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);
}

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

No branches or pull requests

3 participants