Ah ok, but this is what is not happening.

1) Start with TimBL's foaf file from http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf

2) Add foaf:SmartPerson to a random person, say Dean's entry:
<rdf:Description rdf:about="http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf#dj";>
        <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/SmartPerson"/>

3) Then execute the following SPARQL:
construct {?s ?p ?o} where {?s ?p ?o minus {?s ?p <http://xmlns.com/foaf/0.1/NonExistentPerson>}

which results in no changes for Dean's entry since the MINUS matches nothing:
<http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf#dj>
        a                  foaf:Person , foaf:SmartPerson ;
        s:seeAlso <http://www.grorg.org/dean/foaf.rdf> ;
        foaf:homepage      <http://www.grorg.org/dean/> ;
        foaf:mbox          <mailto:[email protected]> , <mailto:[email protected]> ;
        foaf:mbox_sha1sum "6de4ff27ef927b9ba21ccc88257e41a2d7e7d293" ;
        foaf:name          "Dean Jackson" .

4) Then try to match "SmartPerson"
construct {?s ?p ?o} where {?s ?p ?o minus {?s ?p <http://xmlns.com/foaf/0.1/SmartPerson>}

Results in both rdf:type statements being removed but leaving the rest of Dean's entry.
<http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf#dj>
        s:seeAlso <http://www.grorg.org/dean/foaf.rdf> ;
        foaf:homepage      <http://www.grorg.org/dean/> ;
        foaf:mbox          <mailto:[email protected]> , <mailto:[email protected]> ;
        foaf:mbox_sha1sum "6de4ff27ef927b9ba21ccc88257e41a2d7e7d293" ;
        foaf:name          "Dean Jackson" .

5) Then modifying the MINUS statement predicate to be "a" instead of "?p"
construct {?s ?p ?o} where {?s ?p ?o minus {?s a <http://xmlns.com/foaf/0.1/SmartPerson>}

finally results in Dean's entry going away.

        - Erich

=====================================
Erich Bremer
http://www.ebremer.com
http://haylyn.io

On 12/13/13 2:45 AM, Rob Vesse wrote:
Yes that should be the answer

Rob

-----Original Message-----
From: "Erich Bremer" <[email protected]>
Sent: ‎13/‎12/‎2013 06:42
To: "[email protected]" <[email protected]>
Subject: Re: odd SPARQL MINUS behavior Jena 2.11.0

So, if I understand this correctly, if my data is:

<http://sample.com/p1> a :Person; name "Person A"; :nick "Buddy";
:status "Living" .
<http://sample.com/p2> a :Person; name "Person B"; :nick "Bro"; :status
"Living" .
<http://sample.com/p3> a :DeadPerson; name "Person C"; :nick "Butch";
:status "Dead" .

and I give the command:

construct {?s ?p ?o} where {?s ?p ?o minus {?s ?p
<http://xmlns.com/foaf/0.1/DeadPerson>}}"

then I should get the resultant graph:

<http://sample.com/p1> a :Person; name "Person A"; :nick "Buddy";
:status "Living" .
<http://sample.com/p2> a :Person; name "Person B"; :nick "Bro"; :status
"Living" .

       Would this be correct?  - Erich

On 12/11/13 4:25 AM, Andy Seaborne wrote:
On 11/12/13 02:56, Erich Bremer wrote:
In the following segment of code:

String queryString = "construct {?s a ?o} whereccc minus {?s a
<http://xmlns.com/foaf/0.1/Person>}}";
Query query = QueryFactory.create(queryString);
QueryExecution qe = QueryExecutionFactory.create(query,m);
Model whoa = qe.execConstruct();

Rather than remove just the pattern {?s a
<http://xmlns.com/foaf/0.1/Person>}, it removes all types as if the
MINUS pattern was {?s a ?p}
Sound like you want:

FILTER (?o != <http://xmlns.com/foaf/0.1/Person>)

which just excludes any (?s, ?o) row where ?o is foaf:Person.

MINUS will take the left-hand side  "?s a ?o" and the right-hand side
{ ?s a foaf:Person}, and remove all rows from the LHS that match
(=join) with the RHS.

So it removes all rows involving ?s where there is a match for
  {?s a <http://xmlns.com/foaf/0.1/Person>}

See also

FILTER NOT EXISTS {?s a <http://xmlns.com/foaf/0.1/Person>}

which applies a test to ?s for every row to see if can be matched.

In both MINUS and FILTER NOT EXISTS, ?o is not playing a part - it's
not mentioned in the negation side and, in this case, MINUS and FILTER
NOT EXISTS have the same outcome.

     Andy

      - Erich
========================
http://www.ebremer.com
http://haylyn.io


Reply via email to