mapping-master
mapping-master copied to clipboard
Annotations on Object Property declarations
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"))));
}
Looking forward to see this PR approved. Using OP on rules is a must-have.