Re: Programmatically add some instances to an existing ontology
On 10/03/2010 04:16 PM, Reza Moradi rad wrote:
> Please tell me how i can add some instances to an existing ontology
> programmatically (for an specific class) ?
The following two lines create a "Brother" class and an instance
OWLNamedClass brotherClass = owlModel.createOWLNamedClass("Brother");
OWLIndividual individual = brotherClass.createOWLIndividual("Hans");
Please tell me how i can add some instances to an existing
ontology programmatically (for an specific class) ?
Also i need to save new version of ontology in local disc.
I can guess how, but i'm not sure.
One issue with this question is it is not clear what OWL api you are
using. Olivier gave a very good answer assuming that you are using the
Protege 3 OWL api. This would be a natural inference based on the
chosen mailing list. But you then say:
This suggests that you are talking about the Manchester OWL api. For
that I would recommend the documentation at owlapi.sourceforge.net.
This includes programming examples for several different scenarios. In
this api, you don't really create individuals. You create statements
about individuals. The closest thing to what you want would be to add
declarations of named individuals to the ontology. You would do that
with something like (this is definitely pseudo-code - not compileable):