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