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

Annotations on Object Property declarations #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

neobernad
Copy link

@neobernad neobernad commented Sep 11, 2020

Hi,

This pull request extends the syntax in order to define annotations on object properties declarations. For instance:

ObjectProperty: hasParent
    Annotations: skos:prefLabel 'HasParentLabel'

The latter syntax creates an annotation skos:prefLabel with the literal value HasParentLabel to the object property hasParent.
Most of the file changes are due to the re-execution of the JavaCC syntax, which generates many Java files.

Since the tests are in a different project, this is the test code I used appened to BasicTest.java:

/**
    * Test object property with literal annotation.
    * <p>
    * - Precondition: The target object property and annotation property must be predefined in the ontology.
    */
   @Test
   @Category(ClassExpressionTest.class)
   public void TestObjectPropertyWithLiteralAnnotationDeclaration() throws Exception
   {
	  setPrefix(ontology, "skos", "http://www.w3.org/2004/02/skos/core#");
	  declareOWLAnnotationProperty(ontology, "skos:prefLabel");
	  declareOWLObjectProperties(ontology, "hasParent");
	  
	  String expression = "ObjectProperty: hasParent Annotations: skos:prefLabel 'HasParentLabel'";

	  Optional<? extends OWLRendering> result = createOWLAPIRendering(ontology, expression, settings);
	  assertThat(result.isPresent(), is(true));
	
	  Set<OWLAxiom> axioms = result.get().getOWLAxioms();
	  assertThat(axioms, containsInAnyOrder(
	            Declaration(HAS_PARENT),
	            AnnotationAssertion(SKOS_PREFLABEL,IRI(ONTOLOGY_ID, "hasParent"), Literal("HasParentLabel", XSD_STRING))));
   }

/**
    * Test object property with IRI annotation.
    * <p>
    * - Precondition: The target object property and annotation property must be predefined in the ontology.
    */
   @Test
   @Category(ClassExpressionTest.class)
   public void TestObjectPropertyWithIRIAnnotationDeclaration() throws Exception
   {
	  setPrefix(ontology, "foaf", "http://xmlns.com/foaf/0.1/");
	  declareOWLAnnotationProperty(ontology, "foaf:depiction");
	  declareOWLClasses(ontology, "Person", "Human");
	  declareOWLObjectProperties(ontology, "hasParent");
	  
	  String expression = "ObjectProperty: hasParent Annotations: foaf:depiction <https://example.com/img_url.png>";

	  Optional<? extends OWLRendering> result = createOWLAPIRendering(ontology, expression, settings);
	  assertThat(result.isPresent(), is(true));

	  Set<OWLAxiom> axioms = result.get().getOWLAxioms();
	  assertThat(axioms, containsInAnyOrder(
	            Declaration(HAS_PARENT),
	            AnnotationAssertion(FOAF_DEPICTION, IRI(ONTOLOGY_ID, "hasParent"), IRI("https://example.com/img_url.png"))));
   }

@joaovictortinoco
Copy link

Looking forward to see this PR approved. Using OP on rules is a must-have.

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

Successfully merging this pull request may close these issues.

2 participants