Question

I'm trying to write an OWLObjectPropertyExpression on OWL Ontology object. If I had an OWL Class I use something like the following:

 OWLOntologyManager managerWriter = OWLManager.createOWLOntologyManager();
 OWLOntology ontoWrite=managerWriter.createOntology();
 OWLDataFactory factory = manager.getOWLDataFactory();
 managerWriter.addAxiom(ontoWrite,factory.getOWLDeclarationAxiom(factory.getOWLClass((cl.getIRI()))));

But what should I write if I want to write an OWLObjectPropertyExpression ? Thanks in advance !.

Was it helpful?

Solution

The following code snippet illustrate an example of usage and creation of an OWL expression using the OWL API (taken and adapted from there):

//OWL Expression we would like to create:
//in OWL Functional syntax: ObjectIntersectionOf(A ObjectSomeValuesFrom(R B))
//in Manchester syntax: A and R some B
PrefixManager pm = new DefaultPrefixManager("http://example.org/");
OWLClass A = factory.getOWLClass(":A", pm);
OWLObjectProperty R = factory.getOWLObjectProperty(":R", pm);
OWLClass B = factory.getOWLClass(":B", pm);

//The expression
OWLClassExpression expression = 
  factory.getOWLObjectIntersectionOf(A, factory.getOWLObjectSomeValuesFrom(R, B));

//Create a class in order to use the expression
OWLClass C = factory.getOWLClass(":C", pm);

// Declare an equivalentClass axiom
//Just there to show how an example on how to use the expression
OWLAxiom definition = factory.getOWLEquivalentClassesAxiom(C, expression);
manager.addAxiom(ontology, definition);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top