You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by "Abeyruwan, Saminda Wishwajith" <s....@umiami.edu> on 2015/01/26 19:01:45 UTC

Adding NegativePropertyAssertion to ABox

?Hi,


I have a relation "R", which relates individual "a" and "b"; such that R(a,b).


My requirement is to use NegativePropertyAssertion to add


"not" R(a,b) to my ABox.


I'm having some problem figuring out using Jena OWL API to do this. Any pointer regarding how to use Jena OWL API to add a "NegativePropertyAssertion?" to ABox is highly appreciated.


Please let me know.


Thank you! Sam



Saminda Abeyruwan
PhD Student
Dept. of Computer Science,
University of Miami

saminda@cs.miami.edu
(305) 457 9753
http://saminda.org/

Re: Adding NegativePropertyAssertion to ABox

Posted by Martynas Jusevičius <ma...@graphity.org>.
I think an even shorter version should work, as most Resource methods
follow the builder pattern:

    negativePropertyAssertion.addProperty(OWL2.assertionProperty, hasPropertyR).
        addProperty(OWL2.sourceIndividual, sourceIndividual).
        addProperty(OWL2.targetIndividual, targetIndividual);

On Mon, Jan 26, 2015 at 7:56 PM, Joshua TAYLOR <jo...@gmail.com> wrote:
> On Mon, Jan 26, 2015 at 1:33 PM, Abeyruwan, Saminda Wishwajith
> <s....@umiami.edu> wrote:
>>           Property assertionProperty = OWL2.assertionProperty;
>>           Property sourceIndividual = OWL2.sourceIndividual;
>>           Property targetIndividual = OWL2.targetIndividual;
>>           negativePropertyAssertion.addProperty(assertionProperty, hasPropertyR);
>>           negativePropertyAssertion.addProperty(sourceIndividual, sourceIndividual);
>>           negativePropertyAssertion.addProperty(targetIndividual, targetIndividual);
>
> Just as a note, you don't need to assign the properties to variables
> in advance.  You could just do:
>
>     negativePropertyAssertion.addProperty(OWL2.assertionProperty, hasPropertyR);
>     negativePropertyAssertion.addProperty(OWL2.sourceIndividual,
> sourceIndividual);
>     negativePropertyAssertion.addProperty(OWL2.targetIndividual,
> targetIndividual);
>
> //JT
>
>
>
>
>
> --
> Joshua Taylor, http://www.cs.rpi.edu/~tayloj/

Re: Adding NegativePropertyAssertion to ABox

Posted by Joshua TAYLOR <jo...@gmail.com>.
On Mon, Jan 26, 2015 at 1:33 PM, Abeyruwan, Saminda Wishwajith
<s....@umiami.edu> wrote:
>           Property assertionProperty = OWL2.assertionProperty;
>           Property sourceIndividual = OWL2.sourceIndividual;
>           Property targetIndividual = OWL2.targetIndividual;
>           negativePropertyAssertion.addProperty(assertionProperty, hasPropertyR);
>           negativePropertyAssertion.addProperty(sourceIndividual, sourceIndividual);
>           negativePropertyAssertion.addProperty(targetIndividual, targetIndividual);

Just as a note, you don't need to assign the properties to variables
in advance.  You could just do:

    negativePropertyAssertion.addProperty(OWL2.assertionProperty, hasPropertyR);
    negativePropertyAssertion.addProperty(OWL2.sourceIndividual,
sourceIndividual);
    negativePropertyAssertion.addProperty(OWL2.targetIndividual,
targetIndividual);

//JT





-- 
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/

Re: Adding NegativePropertyAssertion to ABox

Posted by "Abeyruwan, Saminda Wishwajith" <s....@umiami.edu>.
Hi Joshua,

Thank you for the swift reply. Using your recommendations and following code:

Resource negativePropertyAssertion = assertionOntModel.createResource(OWL2.NegativePropertyAssertion);
          Property assertionProperty = OWL2.assertionProperty;
          Property sourceIndividual = OWL2.sourceIndividual;
          Property targetIndividual = OWL2.targetIndividual;
          negativePropertyAssertion.addProperty(assertionProperty, hasPropertyR);
          negativePropertyAssertion.addProperty(sourceIndividual, sourceIndividual);
          negativePropertyAssertion.addProperty(targetIndividual, targetIndividual);

manged to create the NegativePropertyAssertion in ABox. 

Thank you! Sam

Saminda Abeyruwan
PhD Student
Dept. of Computer Science,
University of Miami

saminda@cs.miami.edu
(305) 457 9753
http://saminda.org/

________________________________________
From: Joshua TAYLOR <jo...@gmail.com>
Sent: Monday, January 26, 2015 1:17 PM
To: users@jena.apache.org
Subject: Re: Adding NegativePropertyAssertion to ABox

On Mon, Jan 26, 2015 at 1:01 PM, Abeyruwan, Saminda Wishwajith
<s....@umiami.edu> wrote:
> I have a relation "R", which relates individual "a" and "b"; such that R(a,b).
> My requirement is to use NegativePropertyAssertion to add
> "not" R(a,b) to my ABox.
> I'm having some problem figuring out using Jena OWL API to do this. Any pointer regarding how to use Jena OWL API to add a "NegativePropertyAssertion?" to ABox is highly appreciated.

I think that negative object property assertions are an OWL2
construction, and not present in OWL1.  Jena's API does not support
OWL2, but only OWL1.  Thus, there are not built in methods for working
with negative property assertions. Jena's APIs are RDF-centric,
though, and you can manually add the RDF triples that encode the OWL
assertion.  In particular, to add the axiom:

    NegativeObjectPropertyAssertion( OPE a1 a2 )

you would add triples of the following form:

_:x rdf:type owl:NegativePropertyAssertion .
_:x owl:sourceIndividual T(a1) .
_:x owl:assertionProperty T(OPE) .
_:x owl:targetIndividual T(a2) .

(See "OWL 2 Web Ontology Language: Mapping to RDF Graphs" [1] for more
details.)  I'm not sure if I've got an example handy for negated
propety assertions, but my answer to "Can I add annotations to object
property assertion from jena?" on Stack Overflow [2] shows an example
of this type of approach, and may be a helpful starting point.

//JT

[1] http://www.w3.org/TR/owl2-mapping-to-rdf/
[2] http://stackoverflow.com/q/18801414/1281433


--
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/

Re: Adding NegativePropertyAssertion to ABox

Posted by Joshua TAYLOR <jo...@gmail.com>.
On Mon, Jan 26, 2015 at 1:01 PM, Abeyruwan, Saminda Wishwajith
<s....@umiami.edu> wrote:
> I have a relation "R", which relates individual "a" and "b"; such that R(a,b).
> My requirement is to use NegativePropertyAssertion to add
> "not" R(a,b) to my ABox.
> I'm having some problem figuring out using Jena OWL API to do this. Any pointer regarding how to use Jena OWL API to add a "NegativePropertyAssertion?" to ABox is highly appreciated.

I think that negative object property assertions are an OWL2
construction, and not present in OWL1.  Jena's API does not support
OWL2, but only OWL1.  Thus, there are not built in methods for working
with negative property assertions. Jena's APIs are RDF-centric,
though, and you can manually add the RDF triples that encode the OWL
assertion.  In particular, to add the axiom:

    NegativeObjectPropertyAssertion( OPE a1 a2 )

you would add triples of the following form:

_:x rdf:type owl:NegativePropertyAssertion .
_:x owl:sourceIndividual T(a1) .
_:x owl:assertionProperty T(OPE) .
_:x owl:targetIndividual T(a2) .

(See "OWL 2 Web Ontology Language: Mapping to RDF Graphs" [1] for more
details.)  I'm not sure if I've got an example handy for negated
propety assertions, but my answer to "Can I add annotations to object
property assertion from jena?" on Stack Overflow [2] shows an example
of this type of approach, and may be a helpful starting point.

//JT

[1] http://www.w3.org/TR/owl2-mapping-to-rdf/
[2] http://stackoverflow.com/q/18801414/1281433


-- 
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/