removing or replacing dataproperty of and individual

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

removing or replacing dataproperty of and individual

Denis Smirnov

Hey,

how do I remove an existing dataproperty from an individual?

How do I replace the value of a dataproperty of an individual?

 

So Far that’s what I have:

 

                public void removeDataProperty(String individualName, String datapropertyName){

                              

                               OWLNamedIndividual indi = dataFactory.getOWLNamedIndividual(IRI.create(prefix + individualName));

                               OWLDataProperty prop = dataFactory.getOWLDataProperty(IRI.create(prefix + datapropertyName));

                              

                               for(OWLAxiom a: ontology.getAxioms(AxiomType.DATA_PROPERTY_RANGE)){

                                               if(prop.getDataPropertiesInSignature().equals(a.getDataPropertiesInSignature())){

 

                                                               manager.removeAxiom(ontology,????); //What should I use instead of ????  ß

                                                               break;

                                               }}}

 

Thanks

 

Regards

Denis

 

 


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

Re: removing or replacing dataproperty of and individual

Rafael Gonçalves
Hi Denis, 

See answers inline.

How do I replace the value of a dataproperty of an individual?

Remove the old axiom and add a new, updated one.

So Far that’s what I have:
 
                public void removeDataProperty(String individualName, String datapropertyName){
                               
                               OWLNamedIndividual indi = dataFactory.getOWLNamedIndividual(IRI.create(prefix + individualName));
                               OWLDataProperty prop = dataFactory.getOWLDataProperty(IRI.create(prefix + datapropertyName));
                               
                               for(OWLAxiom a: ontology.getAxioms(AxiomType.DATA_PROPERTY_RANGE)){

The axiom type should be AxiomType.DATA_PROPERTY_ASSERTION.

                                               if(prop.getDataPropertiesInSignature().equals(a.getDataPropertiesInSignature())){

Delete this line. If you want confirmation that the axiom contains your data property in its signature, you would do: if( a.getSignature().contains(prop) ). 

But you want to be more precise in this case, since you know the property and subject of the axiom. First cast the axiom as a Data Property Assertion axiom, and then check that the property and subject are the same as your property and individual, like so:

OWLDataPropertyAssertionAxiom dpAx = (OWLDataPropertyAssertionAxiom) a;
if( dpAx.getProperty().equals(prop) && dpAx.getSubject().equals(indi) ) {
manager.removeAxiom( ontology, a ); 
}

Hope this helps.

Cheers,
Rafael

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

Re: removing or replacing dataproperty of and individual

Lorenz Buehmann
In reply to this post by Denis Smirnov

Hi,


what do you mean by "remove a dataproperty from an individual"? If you mean all facts prop(ind, val) such that ind is the individual and prop the data property, then you can use

Collection<OWLLiteral>values = EntitySearcher.getDataPropertyValues(ind, prop, ontology)

to get all values and create the corresponding axioms by

dataFactory.getOWLDataPropertyAssertionAxioms()

and remove those axioms.


Replace can only done by remove the existing axiom and add a new one.


Cheers,
Lorenz

On 28.07.2016 17:21, Denis Smirnov wrote:

Hey,

how do I remove an existing dataproperty from an individual?

How do I replace the value of a dataproperty of an individual?

 

So Far that’s what I have:

 

                public void removeDataProperty(String individualName, String datapropertyName){

                              

                               OWLNamedIndividual indi = dataFactory.getOWLNamedIndividual(IRI.create(prefix + individualName));

                               OWLDataProperty prop = dataFactory.getOWLDataProperty(IRI.create(prefix + datapropertyName));

                              

                               for(OWLAxiom a: ontology.getAxioms(AxiomType.DATA_PROPERTY_RANGE)){

                                               if(prop.getDataPropertiesInSignature().equals(a.getDataPropertiesInSignature())){

 

                                                               manager.removeAxiom(ontology,????); //What should I use instead of ????  ß

                                                               break;

                                               }}}

 

Thanks

 

Regards

Denis

 

 



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


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