Skip to content

Commit

Permalink
support dsp:valueClass (with tests) #22
Browse files Browse the repository at this point in the history
  • Loading branch information
jimkont committed Aug 28, 2014
1 parent 15cbb49 commit 4171aec
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 34 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/> .
@prefix dsp: <http://dublincore.org/dc-dsp#> .


Expand Down Expand Up @@ -121,51 +122,53 @@ rutg:OWLCARD-MAX0 a rut:TestGenerator ;


##########################################
#### TODO: DSP Statement Template valueClass (like domain)
#### TODO: DSP Statement Template valueClass (like range)
##########################################


# Class range wrongly defined
# Class range wrongly defined (single range)
rutg:DSPRANGEC 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 {
?s a dsp:DescriptionTemplate ;
dsp:statementTemplate ?templ.
?templ dsp:property ?P1 ;
dsp:nonLiteralConstraint ?nlt .
?nlt dsp:valueClass ?T1.
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 {
?s a dsp:DescriptionTemplate .
?s dsp:statementTemplate/dsp:property ?P1 .
?s dsp:statementTemplate/dsp:nonLiteralConstraint/dsp:valueClass ?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 }
# don't check for general classes
FILTER ( ?T NOT IN ( owl:Thing, prov:Entity, rdf:Resource, rdf:Class, rdf:Property, schema:Property, schema:Class ))
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 ;
rut:annotationProperty rlog:level ;
rut:annotationValue rlog:ERROR] ;
.

# Class range missing
# Class range missing (single range)
rutg:DSPRANGEC-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 {
?s a dsp:DescriptionTemplate ;
dsp:statementTemplate ?templ.
?templ dsp:property ?P1 ;
dsp:nonLiteralConstraint ?nlt .
?nlt dsp:valueClass ?T1.
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 {
?s a dsp:DescriptionTemplate .
?s dsp:statementTemplate/dsp:property ?P1 .
?s dsp:statementTemplate/dsp:nonLiteralConstraint/dsp:valueClass ?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 }
# don't check for general classes
FILTER ( ?T NOT IN ( owl:Thing, prov:Entity, rdf:Resource, rdf:Class, rdf:Property, schema:Property, schema:Class ))
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 @@ -25,7 +25,7 @@ public class PatternIntegrationTest {

@Before
public void setUp() throws Exception {
// Set of
// /*
testsWithErrors.put("owl/OWLDISJC_Correct.ttl", 0);
testsWithErrors.put("owl/OWLDISJC_Wrong.ttl", 6);
testsWithErrors.put("owl/RDFSRANGE_Correct.ttl", 0);
Expand All @@ -47,9 +47,14 @@ public void setUp() throws Exception {
testsWithErrors.put("dsp/standalone_class_Wrong.ttl", 1);
testsWithErrors.put("dsp/property_cardinality_Correct.ttl", 0);
testsWithErrors.put("dsp/property_cardinality_Wrong.ttl", 5);
testsWithErrors.put("dsp/valueClass_Correct.ttl", 0);
testsWithErrors.put("dsp/valueClass_Wrong.ttl", 1);
testsWithErrors.put("dsp/valueClass-miss_Wrong.ttl", 1);
*/
// Load test ontology from resource
RDFUnitStaticWrapper.initWrapper("", resourcePrefix + "owl/ontology.ttl");
//RDFUnitStaticWrapper.initWrapper("", resourcePrefix + "dsp/dsp_constraints.ttl");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,17 @@ ex:DSPPropCard_x_0
]
.

##############33
# dsp:ValueClass (range)
##############
# dsp:ValueClass (range)

ex:DSPValueClass
a dsp:DescriptionTemplate ;
dsp:statementTemplate [
a dsp:NonLiteralStatementTemplate ;
dsp:property ex:PropValueClass ;
dsp:nonLiteralConstraint [
a dsp:NonLiteralConstraint ;
dsp:valueClass ex:ValueClassClass ;
]
]
.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@prefix ex: <http://example.com/dsp#> .

@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .

# Sample wrong data for testing

ex:error1 ex:PropValueClass ex:Anything . # no range in ex:Anything 1 error

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@prefix ex: <http://example.com/dsp#> .

@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .

# Sample correct data for testing

ex:correct1 ex:PropValueClass ex:Something .

ex:Something a ex:ValueClassClass .
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@prefix ex: <http://example.com/dsp#> .

@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .

# Sample wrong data for testing

ex:error1 ex:PropValueClass ex:Something . # wrong range 1 error

ex:Something a ex:SomeWrongRange .

0 comments on commit 4171aec

Please sign in to comment.