Skip to content

Commit

Permalink
improve range detection / add support for schema:rangeIncludes
Browse files Browse the repository at this point in the history
for now we don't create test cases when there are multiple ranges defined
references #5 and #20
  • Loading branch information
jimkont committed Aug 27, 2014
1 parent 984d341 commit 769b995
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix rlog: <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/rlog#> .
@prefix schema: <http://schema.org/> .

##########################################
#### rdfs:range pattern
Expand All @@ -12,28 +13,23 @@
# Class range wrongly defined
rutg:RDFSRANGEC a rut:TestGenerator ;
dcterms:description """Generate all rdfs:range constrains defined in a schema (when range is wrongly defined)"""@en ;
rut:sparqlGenerator """ select distinct ?P1 ?T1 ?DESCRIPTION where {
{
?P1 rdfs:range ?T1 .
?T1 rdf:type <http://www.w3.org/2000/01/rdf-schema#Class> .
FILTER ( (str(?T1) != "http://www.w3.org/2002/07/owl#Thing") &&
(str(?T1) != "http://www.w3.org/ns/prov#Entity") &&
(str(?T1) != "http://www.w3.org/2000/01/rdf-schema#Resource") &&
(str(?T1) != "http://www.w3.org/2000/01/rdf-schema#Literal") &&
(str(?T1) != "http://www.w3.org/2000/01/rdf-schema#Class") &&
(str(?T1) != "http://www.w3.org/2000/01/rdf-schema#Datatype") &&
(str(?T1) != "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") )
} UNION {
?P1 rdfs:range ?T1 .
?T1 rdf:type <http://www.w3.org/2002/07/owl#Class> .
FILTER ( (str(?T1) != "http://www.w3.org/2002/07/owl#Thing") &&
(str(?T1) != "http://www.w3.org/ns/prov#Entity") &&
(str(?T1) != "http://www.w3.org/2000/01/rdf-schema#Resource") &&
(str(?T1) != "http://www.w3.org/2000/01/rdf-schema#Literal") &&
(str(?T1) != "http://www.w3.org/2000/01/rdf-schema#Class") &&
(str(?T1) != "http://www.w3.org/2000/01/rdf-schema#Datatype") &&
(str(?T1) != "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") )}
BIND (concat(str(?P1)," does not have correct rdfs:range: ", str(?T1)) AS ?DESCRIPTION)} """ ;
rut:sparqlGenerator """ select distinct ?P1 (sample (?T) AS ?T1) (sample(?D) AS ?DESCRIPTION) where {
?P1 (rdfs:range|schema:rangeIncludes) ?T .
# don't check for datatypes / literals here
FILTER NOT EXISTS {?T rdf:type/rdfs:subclassOf* rdfs:Literal }
FILTER NOT EXISTS {?T rdf:type/rdfs:subclassOf* rdfs:Datatype }
FILTER NOT EXISTS {?T rdf:type/rdfs:subclassOf* schema:DataType }
# it must be defined that the range is a class
?T rdf:type/rdfs:subclassOf* ?class .
FILTER ( ?class IN (owl:Class, rdfs:Class) )
# don't check for general classes
FILTER ( ?T NOT IN ( owl:Thing, prov:Entity, rdf:Resource, rdf:Class, rdf:Property ))
BIND (concat(str(?P1)," does not have correct range: ", str(?T)) AS ?D)}
GROUP BY ?P1
HAVING (count(?T) = 1) """ ;
rut:basedOnPattern rutp:RDFSRANGE ;
rut:resultAnnotation [
a rut:ResultAnnotation ;
Expand All @@ -44,28 +40,23 @@ rutg:RDFSRANGEC a rut:TestGenerator ;
# Class range missing
rutg:RDFSRANGEC-MISS a rut:TestGenerator ;
dcterms:description """Generate all rdfs:range constrains defined in a schema (when range is missing)"""@en ;
rut:sparqlGenerator """ select distinct ?P1 ?DESCRIPTION where {
{
?P1 rdfs:range ?T1 .
?T1 rdf:type <http://www.w3.org/2000/01/rdf-schema#Class> .
FILTER ( (str(?T1) != "http://www.w3.org/2002/07/owl#Thing") &&
(str(?T1) != "http://www.w3.org/ns/prov#Entity") &&
(str(?T1) != "http://www.w3.org/2000/01/rdf-schema#Resource") &&
(str(?T1) != "http://www.w3.org/2000/01/rdf-schema#Literal") &&
(str(?T1) != "http://www.w3.org/2000/01/rdf-schema#Class") &&
(str(?T1) != "http://www.w3.org/2000/01/rdf-schema#Datatype") &&
(str(?T1) != "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") )
} UNION {
?P1 rdfs:range ?T1 .
?T1 rdf:type <http://www.w3.org/2002/07/owl#Class> .
FILTER ( (str(?T1) != "http://www.w3.org/2002/07/owl#Thing") &&
(str(?T1) != "http://www.w3.org/ns/prov#Entity") &&
(str(?T1) != "http://www.w3.org/2000/01/rdf-schema#Resource") &&
(str(?T1) != "http://www.w3.org/2000/01/rdf-schema#Literal") &&
(str(?T1) != "http://www.w3.org/2000/01/rdf-schema#Class") &&
(str(?T1) != "http://www.w3.org/2000/01/rdf-schema#Datatype") &&
(str(?T1) != "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") )}
BIND (concat(str(?P1)," does not have defined rdfs:range: ", str(?T1)) AS ?DESCRIPTION)} """ ;
rut:sparqlGenerator """ select distinct ?P1 (sample(?D) AS ?DESCRIPTION) where {
?P1 (rdfs:range|schema:rangeIncludes) ?T .
# don't check for datatypes / literals here
FILTER NOT EXISTS {?T rdf:type/rdfs:subclassOf* rdfs:Literal }
FILTER NOT EXISTS {?T rdf:type/rdfs:subclassOf* rdfs:Datatype }
FILTER NOT EXISTS {?T rdf:type/rdfs:subclassOf* schema:DataType }
# it must be defined that the range is a class
?T rdf:type/rdfs:subclassOf* ?class .
FILTER ( ?class IN (owl:Class, rdfs:Class) )
# don't check for general classes
FILTER ( ?T NOT IN ( owl:Thing, prov:Entity, rdf:Resource, rdf:Class, rdf:Property ))
BIND (concat(str(?P1)," does not have correct range: ", str(?T)) AS ?D)}
GROUP BY ?P1
HAVING (count(?T) = 1) """ ;
rut:basedOnPattern rutp:RDFSRANGE-MISS ;
rut:resultAnnotation [
a rut:ResultAnnotation ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@prefix prov: <http://www.w3.org/ns/prov#>.
@prefix spin: <http://spinrdf.org/spin#> .
@prefix dsp: <http://dublincore.org/dc-dsp#> .
@prefix schema: <http://schema.org/> .

@prefix rutp: <http://rdfunit.aksw.org/data/patterns#> .
@prefix rut: <http://rdfunit.aksw.org/ns/core#> .
Expand Down

0 comments on commit 769b995

Please sign in to comment.