W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > April to June 2010

4 MINUS and NOT EXISTS test cases

From: Chimezie Ogbuji <ogbujic@ccf.org>
Date: Tue, 29 Jun 2010 10:25:40 -0400
To: "SPARQL Working Group WG" <public-rdf-dawg@w3.org>
Message-ID: <C84F7AA4.12342%ogbujic@ccf.org>
This discharges my action ( Action-194 ) to collect testcases for negation:

Test case 1.1: Subsets by exclusion (NOT EXISTS)

==== Data
@prefix ex <negation/subset-exclusion#> .
ex:lifeForm1 a ex:Mammal, ex:Animal .
ex:lifeForm2 a ex:Reptile, ex:Animal .
ex:lifeForm3 a ex:Insect, ex:Animal .
====

==== Query
PREFIX ex: <negation/subset-exclusion#>
SELECT ?animal { 
  ?animal a ex:Animal
  FILTER NOT EXISTS { ?animal a ex:Insect }
}
====

==== Solutions
----------------
| animal       |
================
| ex:lifeForm1 |
================
| ex:lifeForm2 |
----------------
====

Test case 1.2: Subsets by exclusion (MINUS)

==== Data
@prefix ex <negation/subset-exclusion#> .
ex:lifeForm1 a ex:Mammal, ex:Animal .
ex:lifeForm2 a ex:Reptile, ex:Animal .
ex:lifeForm3 a ex:Insect, ex:Animal .
====

==== Query
PREFIX ex: <negation/subset-exclusion#>
SELECT ?animal { 
  ?animal a ex:Animal MINUS {
    ?animal a ?type
    FILTER(?type = ex:Reptile && ?type = ex:Insect)
  } 
}
====

==== Solutions
----------------
| animal       |
================
| ex:lifeForm1 |
----------------
====

Test case 2.1: Medical, temporal proximity by exclusion (NOT EXISTS)

==== Data
@prefix ex <negation/temporal-exclusion#> .
@prefix dc <http://purl.org/dc/elements/1.1/> .
@prefix xsd <http://www.w3.org/2001/XMLSchema#> .
ex:examination1 a ex:PhysicalExamination;
                dc:date "2010-01-10"^^xsd:date .
ex:operation1 a ex:SurgicalProcedure;
              dc:date "2010-01-15"^^xsd:date .
ex:examination2 a ex:PhysicalExamination;
                dc:date "2010-01-02"^^xsd:date .
ex:examination1 ex:precedes ex:operation1  .
ex:examination2 ex:precedes ex:operation1  .
ex:examination2 ex:precedes ex:examintion1 .
====

==== Query
PREFIX ex: <negation/temporal-exclusion#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
# The closest pre-operative physical examination
SELECT ?exam ?date {
  ?exam a ex:PhysicalExamination;
        dc:date ?date;
        ex:precedes ex:operation1 .
  ?op   a ex:SurgicalProcedure; dc:date ?opDT .
  FILTER NOT EXISTS {
    ?otherExam a ex:PhysicalExamination;
               ex:follows ?exam;
               ex:precedes ex:operation1
  } 
}
====

==== Solutions
--------------------------------------------
| exam            | date                   |
============================================
| ex:examination1 | "2010-01-10"^^xsd:date |
--------------------------------------------
====

Test case 2.2: Medical, temporal proximity by exclusion (MINUS)

==== Data
@prefix ex <negation/temporal-exclusion#> .
@prefix dc <http://purl.org/dc/elements/1.1/> .
@prefix xsd <http://www.w3.org/2001/XMLSchema#> .
ex:examination1 a ex:PhysicalExamination;
                dc:date "2010-02-10"^^xsd:date .
ex:operation1 a ex:SurgicalProcedure;
              dc:date "2010-03-20"^^xsd:date .
ex:examination2 a ex:PhysicalExamination;
                dc:date "2010-03-11"^^xsd:date .
====

==== Query
PREFIX ex: <negation/temporal-exclusion#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
# The closest pre-operative physical examination
SELECT ?exam ?date {
  ?exam a ex:PhysicalExamination;
        dc:date ?date .
  ?op   a ex:SurgicalProcedure; dc:date ?opDT .
  MINUS {
    ?otherExam a ex:PhysicalExamination; dc:date ?otherExDT
    FILTER(?date < ?otherExDT && ?otherExDT < ?opDT)
  }
  FILTER(?date < ?opDT)
}
====

==== Solutions
--------------------------------------------
| exam            | date                   |
============================================
| ex:examination2 | "2010-03-11"^^xsd:date |
--------------------------------------------
====

-- Chime



===================================

P Please consider the environment before printing this e-mail

Cleveland Clinic is ranked one of the top hospitals
in America by U.S.News & World Report (2009).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use
only by the individual or entity to which it is addressed
and may contain information that is privileged,
confidential, and exempt from disclosure under applicable
law.  If the reader of this message is not the intended
recipient or the employee or agent responsible for
delivering the message to the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  If
you have received this communication in error,  please
contact the sender immediately and destroy the material in
its entirety, whether electronic or hard copy.  Thank you.
Received on Tuesday, 29 June 2010 14:34:20 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:42 GMT