EARL patch up SPARQL

I had an action to write some SPARQL, it's attached, and so is the fixed 
up version of the EARL that Chime sent recently.

It applies the following heuristic:

If two tests have the same input document, and one passes and the other 
fails, then the failing test was not applicable.

It deletes such
   ?s earl:validity earl:fail triples,
and replaces them with
   ?s earl:validity earl:notApplicable ones

It also adds the t:inputDocument triples used to make such analysis.

This is a little unsatisfactory because I am changing someone else 
earl:Assertion's, rather than making new ones.

I have an alternative query that actually makes new assertions, also 
attached, but it doesn't work :(

Jeremy



-- 
Hewlett-Packard Limited
registered Office: Cain Road, Bracknell, Berks RG12 1HN
Registered No: 690597 England
PREFIX earl: <http://www.w3.org/ns/earl#>
PREFIX gtd: <http://www.w3.org/2001/sw/grddl-wg/td/>
PREFIX t: <http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dc:  <http://purl.org/dc/elements/1.1/>

CONSTRUCT { 
# inputDocument triples
        ?test t:inputDocument ?input .
# copy everything except failures.
         ?s ?p ?o .
# real failures
         ?sf earl:validity earl:fail .
# new notApplicable's
         ?s1 earl:validity earl:notApplicable  .
         ?a1 
            earl:mode  earl:heuristic .    
 }
#FROM <http://lists.w3.org/Archives/Public/public-grddl-wg/2007Apr/att-0029/GRDDLpy-earl-2007-04-09.rdf>
#FROM NAMED gtd:grddl-tests
WHERE { 
# The order of the OPTIONALs below is logically irrelevant.
# This order works with the SPARQL engine I am using (ARQ from SVN).

# real failures:
# Distinguished by lack of a test with the same input
# that has passed.
    OPTIONAL 
          { ?sf earl:validity earl:fail .
            ?af earl:result ?sf .
            ?af earl:test ?tf .
              GRAPH gtd:grddl-tests {
               ?tf t:inputDocument ?inf .
              }  
             OPTIONAL
             {            
              GRAPH gtd:grddl-tests {              
                ?t2f t:inputDocument ?inf .
              }
              ?a2f earl:test ?t2f .
              ?a2f earl:result ?s2f .
              ?s2f earl:validity earl:pass .
             }
             FILTER ( ! bound(?s2f) )
           }
# New notApplicables
# Distinguished by being a failing test, but where there is
# a passing test with the same input.
    OPTIONAL
           { ?s1 earl:validity earl:fail .
             ?a1 earl:result ?s1 .
             ?a1 earl:test ?t1 .
             ?a1 earl:subject ?subject .
             GRAPH gtd:grddl-tests {
               ?t1 t:inputDocument ?in .
               ?t2 t:inputDocument ?in .
             }             
             ?pass earl:test ?t2 .
             ?pass earl:result ?s2 .
             ?s2 earl:validity earl:pass .             
             ?pass earl:subject ?subject .
             ?pass earl:assertedBy ?assertor .
          }
# inputDocument triples
    OPTIONAL {
              GRAPH gtd:grddl-tests {
               ?test t:inputDocument ?input .
              }  
    }
# copy everything except failures.
    OPTIONAL 
           {?s ?p ?o . 
              FILTER ( ! (?p = earl:validity && ?o = earl:fail ) ) } 


}
PREFIX earl: <http://www.w3.org/ns/earl#>
PREFIX gtd: <http://www.w3.org/2001/sw/grddl-wg/td/>
PREFIX t: <http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dc:  <http://purl.org/dc/elements/1.1/>

CONSTRUCT { 
# inputDocument triples
        ?testx t:inputDocument ?input .
# copy everything except failures.
         ?s ?p ?o .
# real failures
         ?sf earl:validity earl:fail .
# new notApplicable's
         [] rdf:type earl:Assertion ;
            earl:result [
             rdf:type earl:TestResult ;
             rdfs:seeAlso ?pass ;         
             earl:validity earl:notApplicable  
            ]  ;          
            earl:mode  earl:heuristic ;  
            earl:subject ?subject ;
            earl:test    ?test ;
            earl:assertedBy [
             rdf:type earl:CompoundAssertor ;
             earl:mainAssertor ?assertor ;
             earl:helpAssertor <> 
            ].
         <> rdf:type earl:Software .
         <> dc:title "SPARQL to Patch-up EARL for GRDDL" .
         <> dc:creator "Jeremy J. Carroll" .
     }
FROM <http://lists.w3.org/Archives/Public/public-grddl-wg/2007Apr/att-0029/GRDDLpy-earl-2007-04-09.rdf>
FROM NAMED gtd:grddl-tests
WHERE { 
# real failures:
# Distinguished by lack of a test with the same input
# that has passed.
    OPTIONAL 
          { ?sf earl:validity earl:fail .
            ?af earl:result ?sf .
            ?af earl:test ?tf .
              GRAPH gtd:grddl-tests {
               ?tf t:inputDocument ?inf .
              }  
             OPTIONAL
             {            
              GRAPH gtd:grddl-tests {              
                ?t2f t:inputDocument ?inf .
              }
              ?a2f earl:test ?t2f .
              ?a2f earl:result ?s2f .
              ?s2f earl:validity earl:pass .
             }
             FILTER ( ! bound(?s2f) )
           }
# New notApplicables
# Distinguished by being a failing test, but where there is
# a passing test with the same input.
    OPTIONAL
           { ?s1 earl:validity earl:fail .
             ?a1 earl:result ?s1 .
             ?a1 earl:test ?test .
             ?a1 earl:subject ?subject .
             GRAPH gtd:grddl-tests {
               ?t1 t:inputDocument ?in .
               ?t2 t:inputDocument ?in .
             }             
             ?pass earl:test ?t2 .
             ?pass earl:result ?s2 .
             ?s2 earl:validity earl:pass .             
             ?pass earl:subject ?subject .
             ?pass earl:assertedBy ?assertor .
          }
# inputDocument triples
    OPTIONAL {
              GRAPH gtd:grddl-tests {
               ?testx t:inputDocument ?input .
              }  
    }
# copy everything except failures.
    OPTIONAL 
           {?s ?p ?o . 
              FILTER ( ! (?p = earl:validity && ?o = earl:fail ) ) } 
}

Received on Thursday, 12 April 2007 14:31:04 UTC