Adding a Named Individual to an Ontology via Plugin

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding a Named Individual to an Ontology via Plugin

kcason

I’ve written a Protégé plugin that allows the user to bring up a JPanel to enter two current Named Individuals (say: ind1 and ind2).

These two individuals are valid and already included in the ontology.

 

Now I need to create a new Named Individual that will relate these two together per certain rules, which aren’t import right now.

The new individual would look something like this:

 

    <owl:NamedIndividual rdf:about="http://www.radiancetech.com/myont#ind1andind2relation">                                                     

       <hasDisease rdf:resource="http://www.radiancetech.com/myont#ind1"/>                                                  

       <producesEffect rdf:resource="http://www.radiancetech.com/myont#ind2"/>                                                           

    </owl:NamedIndividual>                                                                                                                                             

 

I’ve looked throughout the Protégé code but all editing is done via gui elements, but I need to add this individual using

data I have that might not have come from a JPanel. I just need to create the above Named Individual using code.

 

Does Protégé have the code already written to do this? If so, can you please supply an example of how to call it?

If not, how would I do it using (I assume) the OWL API?

 

Thanks,

 

-Kenny Cason

Radiance Technologies

Cyber Solutions Group

3133 General Hudnell Dr. Ste. 116
San Antonio, TX 78226

[hidden email]

206.550.0049

 


_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Adding a Named Individual to an Ontology via Plugin

Lorenz Buehmann


The usage of

OWLModelManager modelManager = getOWLEditorKit().getOWLModelManager()

is what you should have access to from the plugins main class.

The instance of OWLModelManager then gives you access to the active ontology, ontology manager as well as the datafactory via

getActiveOntology()

getOWLOntologyManager()

getOWLDataFactory()


So you can use the factory to create the axioms (probably some OWLObjectPropertyAssertionAxiom ) you have in mind and add those to the ontology via the manager.

I’ve written a Protégé plugin that allows the user to bring up a JPanel to enter two current Named Individuals (say: ind1 and ind2).

These two individuals are valid and already included in the ontology.

 

Now I need to create a new Named Individual that will relate these two together per certain rules, which aren’t import right now.

The new individual would look something like this:

 

    <owl:NamedIndividual rdf:about="http://www.radiancetech.com/myont#ind1andind2relation">                                                     

       <hasDisease rdf:resource="http://www.radiancetech.com/myont#ind1"/>                                                  

       <producesEffect rdf:resource="http://www.radiancetech.com/myont#ind2"/>                                                           

    </owl:NamedIndividual>                                                                                                                                             

 

I’ve looked throughout the Protégé code but all editing is done via gui elements, but I need to add this individual using

data I have that might not have come from a JPanel. I just need to create the above Named Individual using code.

 

Does Protégé have the code already written to do this? If so, can you please supply an example of how to call it?

If not, how would I do it using (I assume) the OWL API?

 

Thanks,

 

-Kenny Cason

Radiance Technologies

Cyber Solutions Group

3133 General Hudnell Dr. Ste. 116
San Antonio, TX 78226

[hidden email]

206.550.0049

 


_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Adding a Named Individual to an Ontology via Plugin

kcason

I can create a Named Individual object, given your suggested code below.

 

But as far as I can tell this is an object separate from the ontology. I’ve exported the data and the new individual is not there.

 

I would like to add this object to the current ontology. I see the method: OWLOntologyManager.applyChange(chg) but am not sure how/if to use this method to do so.

 

Here is what I have:

 

OWLModelManager myModelManager = this.modelManager;

OWLOntology myOntology = myModelManager.getActiveOntology();

OWLOntologyManager myOntologyManager = myOntology.getOWLOntologyManager();

OWLDataFactory myDataFactory = myOntologyManager.getOWLDataFactory();

String nextCClass = getNextCClassname(); // ß returns a new valid individual name


OWLNamedIndividual myInd = myDataFactory.getOWLNamedIndividual(nextCClass, PrefixUtilities.getPrefixOWLOntologyFormat(myOntology));


//myOntologyManager.addTheDarnedThing(myInd); // ß this is kinda what I want to do

 

So, given an OWLNamedIndividual and an ontology how do I add the individual to the ontology?

 

-Kenny

 

From: protege-dev <[hidden email]> On Behalf Of Lorenz B.
Sent: Saturday, December 29, 2018 2:33 AM
To: [hidden email]
Subject: Re: [protege-dev] Adding a Named Individual to an Ontology via Plugin

 

 

 

The usage of

OWLModelManager modelManager = getOWLEditorKit().getOWLModelManager()

is what you should have access to from the plugins main class.

The instance of OWLModelManager then gives you access to the active ontology, ontology manager as well as the datafactory via

getActiveOntology()

getOWLOntologyManager()

getOWLDataFactory()

 

So you can use the factory to create the axioms (probably some OWLObjectPropertyAssertionAxiom ) you have in mind and add those to the ontology via the manager.

 

I’ve written a Protégé plugin that allows the user to bring up a JPanel to enter two current Named Individuals (say: ind1 and ind2).

These two individuals are valid and already included in the ontology.

 

Now I need to create a new Named Individual that will relate these two together per certain rules, which aren’t import right now.

The new individual would look something like this:

 

    <owl:NamedIndividual rdf:about="http://www.radiancetech.com/myont#ind1andind2relation">                                                     

       <hasDisease rdf:resource="http://www.radiancetech.com/myont#ind1"/>                                                  

       <producesEffect rdf:resource="http://www.radiancetech.com/myont#ind2"/>                                                           

    </owl:NamedIndividual>                                                                                                                                             

 

I’ve looked throughout the Protégé code but all editing is done via gui elements, but I need to add this individual using

data I have that might not have come from a JPanel. I just need to create the above Named Individual using code.

 

Does Protégé have the code already written to do this? If so, can you please supply an example of how to call it?

If not, how would I do it using (I assume) the OWL API?

 

Thanks,

 

-Kenny Cason

Radiance Technologies

Cyber Solutions Group

3133 General Hudnell Dr. Ste. 116
San Antonio, TX 78226

[hidden email]

206.550.0049

 



_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Adding a Named Individual to an Ontology via Plugin

Lorenz Buehmann
Looks like you missed some parts of my last sentence
So you can use the factory to create the axioms (probably some OWLObjectPropertyAssertionAxiom ) you have in mind and add those to the ontology via the manager.

Creating an individual does nothing. I mean, it doesn't say anything and an ontology is about statements aka axioms. An OWL ontology is made of axioms, so you have to create an axiom and add it to the ontology. If you just want to say that there is an individual, ok - but even then you have to create an axiom, in that case a declaration axiom. But, the more common axiom for individuals are indeed class assertions and property assertions.

Once you created the axiom, you have to add it to the ontology. The OWLOntologyManager provides a method addAxiom in addition to applyChange (AddAxiom would be what you need here by the way)


I can create a Named Individual object, given your suggested code below.

 

But as far as I can tell this is an object separate from the ontology. I’ve exported the data and the new individual is not there.

 

I would like to add this object to the current ontology. I see the method: OWLOntologyManager.applyChange(chg) but am not sure how/if to use this method to do so.

 

Here is what I have:

 

OWLModelManager myModelManager = this.modelManager;

OWLOntology myOntology = myModelManager.getActiveOntology();

OWLOntologyManager myOntologyManager = myOntology.getOWLOntologyManager();

OWLDataFactory myDataFactory = myOntologyManager.getOWLDataFactory();

String nextCClass = getNextCClassname(); // ß returns a new valid individual name


OWLNamedIndividual myInd = myDataFactory.getOWLNamedIndividual(nextCClass, PrefixUtilities.getPrefixOWLOntologyFormat(myOntology));


//myOntologyManager.addTheDarnedThing(myInd); // ß this is kinda what I want to do

 

So, given an OWLNamedIndividual and an ontology how do I add the individual to the ontology?

 

-Kenny

 

From: protege-dev [hidden email] On Behalf Of Lorenz B.
Sent: Saturday, December 29, 2018 2:33 AM
To: [hidden email]
Subject: Re: [protege-dev] Adding a Named Individual to an Ontology via Plugin

 

 

 

The usage of

OWLModelManager modelManager = getOWLEditorKit().getOWLModelManager()

is what you should have access to from the plugins main class.

The instance of OWLModelManager then gives you access to the active ontology, ontology manager as well as the datafactory via

getActiveOntology()

getOWLOntologyManager()

getOWLDataFactory()

 

So you can use the factory to create the axioms (probably some OWLObjectPropertyAssertionAxiom ) you have in mind and add those to the ontology via the manager.

 

I’ve written a Protégé plugin that allows the user to bring up a JPanel to enter two current Named Individuals (say: ind1 and ind2).

These two individuals are valid and already included in the ontology.

 

Now I need to create a new Named Individual that will relate these two together per certain rules, which aren’t import right now.

The new individual would look something like this:

 

    <owl:NamedIndividual rdf:about="http://www.radiancetech.com/myont#ind1andind2relation">                                                     

       <hasDisease rdf:resource="http://www.radiancetech.com/myont#ind1"/>                                                  

       <producesEffect rdf:resource="http://www.radiancetech.com/myont#ind2"/>                                                           

    </owl:NamedIndividual>                                                                                                                                             

 

I’ve looked throughout the Protégé code but all editing is done via gui elements, but I need to add this individual using

data I have that might not have come from a JPanel. I just need to create the above Named Individual using code.

 

Does Protégé have the code already written to do this? If so, can you please supply an example of how to call it?

If not, how would I do it using (I assume) the OWL API?

 

Thanks,

 

-Kenny Cason

Radiance Technologies

Cyber Solutions Group

3133 General Hudnell Dr. Ste. 116
San Antonio, TX 78226

[hidden email]

206.550.0049

 



_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev