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

Add Annotation to the ObjectPropertyRange #235

Closed
JProphet89 opened this issue Jul 1, 2014 · 6 comments
Closed

Add Annotation to the ObjectPropertyRange #235

JProphet89 opened this issue Jul 1, 2014 · 6 comments
Labels

Comments

@JProphet89
Copy link

Anyone knows who to add a simple annotation to a ObjectPropertyRange like the example bellow?

captura de ecra 2014-07-1 as 12 01 52

@JProphet89 JProphet89 changed the title Add Annotation to the ObjectPropertyRange Add Annotation to the ObjectPropertyRange :question Jul 1, 2014
@JProphet89 JProphet89 changed the title Add Annotation to the ObjectPropertyRange :question Add Annotation to the ObjectPropertyRange Jul 1, 2014
@sesuncedu
Copy link
Contributor

[Data factory has a range axiom builder method that takes a set of Annotations](http://owlapi.sourceforge.net/javadoc/org/semanticweb/owlapi/model/OWLDataFactory.html#getOWLObjectPropertyRangeAxiom%28org.semanticweb.owlapi.model.OWLObjectPropertyExpression, org.semanticweb.owlapi.model.OWLClassExpression, java.util.Set%29).

OWLDataFactory::getOWLObjectPropertyRangeAxiom if the markdown ate that link.

@ignazio1977
Copy link
Contributor

To give a complete code snippet:

OWLDataFactory df = ...
OWLAnnotationProperty  p=df.getOWLAnnotationProperty(IRI.create("urn:test#backwardCompatibleWith"));
OWLAnnotation ann=df.getOWLAnnotation(p, IRI.create("urn:test#languageDesign"));
OWLObjectProperty op=df.getOWLObjectProperty(IRI.create("urn:test#produces"));
OWLClass c = df.getOWLClass(IRI.create("urn:test#ProgramLanguage"));
OWLObjectPropertyRangeAxiom axiom=df.getOWLObjectPropertyRangeAxiom(op, c, Collections.singleton(ann));

At this point, add the axiom to your ontology and save in the preferred format. From the example, I'm guessing that's OWL/XML.

@ignazio1977
Copy link
Contributor

Given the number of questions I see about how to add annotations, a few more examples should be added to the documentation.

@JProphet89
Copy link
Author

this resolve my problem i finally got it

OWLAnnotationValue val=domain.getIRI();
OWLAnnotation annotation = df.getOWLAnnotation(df.getOWLBackwardCompatibleWith(),val);
OWLObjectPropertyRangeAxiom owlObjectPropertyRangeAxiom=df.getOWLObjectPropertyRangeAxiom(objectProperty, range,new HashSet(Arrays.asList(annotation)));

@ignazio1977
Copy link
Contributor

Note that

new HashSet(Arrays.asList(annotation))

is equivalent to

Collections.singleton(annotation)

@matthewhorridge
Copy link
Contributor

Note that you can also get an annotated copy of an existing axiom. There's

OWLAxiom getAnnotatedAxiom(Set<OWLAnnotation> annotations);

Note that this returns a copy of the axioms that the method is called on.

@owlcs owlcs deleted a comment from hafsabajwa Feb 12, 2022
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

4 participants