Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OWL Individual in java

Tags:

java

owl

ontology

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

like image 411
nunoaac Avatar asked Nov 15 '11 14:11

nunoaac


1 Answers

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.

like image 61
ynka Avatar answered Nov 17 '22 10:11

ynka