I'm trying to access ontologies via Eclipse. I use the owl-api. I create my ontologies in Protegé, however I want to create and classify new INDIVIDUALS by code. How is that possible? I googled everything but I can't find any useful info.
Macro-example: - ontology 'a' which has the entities 'B', 'C' and 'D'. - I create an individual 'z' and I want to figure if it can be part of 'B', 'C', 'D' or none of the entities.
I face 3 problems: - I don't know how to create an individual of a type - I don't know how to fill the data properties of the individual. - I don't know hot to get the reasoner working (well, i haven't tried it yet since I can't do the previous steps).
Can you help me? Thanks in advance!
Nuno
OWL API has cool documentation here: http://owlapi.sourceforge.net/documentation.html
So, to create an individual of a class:
OWLClass person = dataFactory.getOWLClass(":Person", pm);
OWLNamedIndividual mary = dataFactory.getOWLNamedIndividual(":Mary", pm);
OWLClassAssertionAxiom classAssertion = dataFactory.getOWLClassAssertionAxiom(person, mary);
manager.addAxiom(ontology, classAssertion);
To add some properties:
OWLIndividual matthew = dataFactory.getOWLNamedIndividual(IRI.create(base + "#matthew"));
OWLIndividual peter = dataFactory.getOWLNamedIndividual(IRI.create(base + "#peter"));
OWLObjectProperty hasFather = dataFactory.getOWLObjectProperty(IRI.create(base + "#hasFather"));
OWLObjectPropertyAssertionAxiom assertion = dataFactory.getOWLObjectPropertyAssertionAxiom(hasFather, matthew, peter);
There is a reasoner example too, but it's longer, so check yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With