diff --git a/rdfunit-core/src/main/resources/org/aksw/rdfunit/autoGeneratorsOWL.ttl b/rdfunit-core/src/main/resources/org/aksw/rdfunit/autoGeneratorsOWL.ttl index 6139b7f00..0487ff23a 100644 --- a/rdfunit-core/src/main/resources/org/aksw/rdfunit/autoGeneratorsOWL.ttl +++ b/rdfunit-core/src/main/resources/org/aksw/rdfunit/autoGeneratorsOWL.ttl @@ -64,10 +64,14 @@ rutg:RDFSRANGEC-MISS a rut:TestGenerator ; rut:annotationValue rlog:WARN] ; . +########################################## +#### Literals / Datatypes +########################################## + # Check for Literal rutg:RDFSRANGEL a rut:TestGenerator ; dcterms:description """Check all defined Literals if they are indeed literals"""@en ; - rut:sparqlGenerator """ select distinct ?P1 ('!' as ?NEG) ('isLiteral' as ?FUNC) ?DESCRIPTION where { + rut:sparqlGenerator """ select distinct ?P1 ('' as ?NEG) ('isIRI' as ?FUNC) ?DESCRIPTION where { { # xsd datatypes ?P1 rdfs:range ?D1 . FILTER ( STRSTARTS(str(?D1), "http://www.w3.org/2001/XMLSchema#") ). @@ -92,6 +96,19 @@ rutg:RDFSRANGEL a rut:TestGenerator ; rut:annotationValue rlog:ERROR] ; . +# Check for rdf:langString +rutg:RDFLANGSTRING a rut:TestGenerator ; + dcterms:description """Check all defined Literals if they are indeed literals"""@en ; + rut:sparqlGenerator """ select distinct ?P1 ('=' as ?OP) ('' as ?V1) ?DESCRIPTION where { + ?P1 rdfs:range rdf:langString . + BIND (concat(str(?P1)," is an rdf:langString and should have a language") AS ?DESCRIPTION)} """ ; + rut:basedOnPattern rutp:CHECKLANG; + rut:resultAnnotation [ + a rut:ResultAnnotation ; + rut:annotationProperty rlog:level ; + rut:annotationValue rlog:ERROR] ; + . + # Datatype range rutg:RDFSRANGED a rut:TestGenerator ; dcterms:description """Generate all rdfs:range constrains defined in a schema"""@en ; diff --git a/rdfunit-core/src/main/resources/org/aksw/rdfunit/patterns.ttl b/rdfunit-core/src/main/resources/org/aksw/rdfunit/patterns.ttl index 6c0be6a7f..afabd6541 100644 --- a/rdfunit-core/src/main/resources/org/aksw/rdfunit/patterns.ttl +++ b/rdfunit-core/src/main/resources/org/aksw/rdfunit/patterns.ttl @@ -866,6 +866,50 @@ rutp:OBJFUNC-FUNC a rut:Parameter ; rut:parameterConstraint rut:None . +################################################################################ +#### CHECKLANG +#### Check the language of an object for a specific value +#### (e.g. foaf:name should have an english language) +################################################################################ + +rutp:CHECKLANG a rut:Pattern ; + dcterms:identifier "CHECKLANG" ; + dcterms:description """Resource has more than one plain literal of a certain language assigned"""@en ; + rut:sparqlWherePattern """ { + ?resource %%P1%% ?c . + FILTER ( lang(?c) %%OP%% '%%V1%%') . + } """ ; + rut:sparqlPrevalencePattern """ SELECT (count( DISTINCT ?resource) AS ?total) + WHERE { ?resource %%P1%% ?c .}""" ; + rut:parameter rutp:CHECKLANG-P1 ; + rut:parameter rutp:CHECKLANG-OP ; + rut:parameter rutp:CHECKLANG-V1 ; + rut:resultAnnotation [ + a rut:ResultAnnotation ; + rut:annotationProperty spin:violationPath ; + rut:annotationValue """%%P1%%""" + ]; + rut:resultAnnotation [ + a rut:ResultAnnotation ; + rut:annotationProperty spin:violationValue ; + rut:annotationValue """?c""" + ]; + . + +rutp:CHECKLANG-P1 a rut:Parameter ; + dcterms:identifier "P1" ; + rut:parameterConstraint rut:Property . + +rutp:CHECKLANG-OP a rut:Parameter ; + dcterms:identifier "OP" ; + rut:parameterConstraint rut:Operator ; + rut:constraintPattern """<|<=|>|>=|=|!=""" . + +rutp:CHECKLANG-V1 a rut:Parameter ; + dcterms:identifier "V1" ; + rut:parameterConstraint rut:None . + + ################################################################################ #### ONELANG #### Resource has more than one plain literal of a certain language assigned diff --git a/rdfunit-validate/src/test/java/org/aksw/rdfunit/validate/integration/PatternIntegrationTest.java b/rdfunit-validate/src/test/java/org/aksw/rdfunit/validate/integration/PatternIntegrationTest.java index a14f029d5..b69ec171b 100644 --- a/rdfunit-validate/src/test/java/org/aksw/rdfunit/validate/integration/PatternIntegrationTest.java +++ b/rdfunit-validate/src/test/java/org/aksw/rdfunit/validate/integration/PatternIntegrationTest.java @@ -39,6 +39,8 @@ public void setUp() throws Exception { testsWithErrors.put("owl/OWLCARDT_Wrong_Exact.ttl", 6); testsWithErrors.put("owl/OWLCARDT_Wrong_Min.ttl", 2); testsWithErrors.put("owl/OWLCARDT_Wrong_Max.ttl", 2); + testsWithErrors.put("owl/RDFLANGSTRING_Correct.ttl", 0); + testsWithErrors.put("owl/RDFLANGSTRING_Wrong.ttl", 2); /* testsWithErrors.put("dsp/standalone_class_Correct.ttl", 0); diff --git a/rdfunit-validate/src/test/resources/org/aksw/rdfunit/validate/data/owl/RDFLANGSTRING_Correct.ttl b/rdfunit-validate/src/test/resources/org/aksw/rdfunit/validate/data/owl/RDFLANGSTRING_Correct.ttl new file mode 100644 index 000000000..da0669383 --- /dev/null +++ b/rdfunit-validate/src/test/resources/org/aksw/rdfunit/validate/data/owl/RDFLANGSTRING_Correct.ttl @@ -0,0 +1,14 @@ +@prefix ex: . + +@prefix xsd: . +@prefix rdf: . +@prefix rdfs: . +@prefix owl: . + +# Sample correct data for testing + + +ex:correct1 ex:langStringProperty + "asdf"@en , + "asdf"@de , + "sdfg"@it . \ No newline at end of file diff --git a/rdfunit-validate/src/test/resources/org/aksw/rdfunit/validate/data/owl/RDFLANGSTRING_Wrong.ttl b/rdfunit-validate/src/test/resources/org/aksw/rdfunit/validate/data/owl/RDFLANGSTRING_Wrong.ttl new file mode 100644 index 000000000..6b5ac80b9 --- /dev/null +++ b/rdfunit-validate/src/test/resources/org/aksw/rdfunit/validate/data/owl/RDFLANGSTRING_Wrong.ttl @@ -0,0 +1,15 @@ +@prefix ex: . + +@prefix xsd: . +@prefix rdf: . +@prefix rdfs: . +@prefix owl: . + +# Sample correct data for testing + + +ex:correct1 ex:langStringProperty + "asdf" , # 1 error + "asdf"@de , + "sdfg"@it , + ex:someValue . # 1 error (checked with isLiteral generator) \ No newline at end of file diff --git a/rdfunit-validate/src/test/resources/org/aksw/rdfunit/validate/data/owl/ontology.ttl b/rdfunit-validate/src/test/resources/org/aksw/rdfunit/validate/data/owl/ontology.ttl index 226777967..107044f02 100644 --- a/rdfunit-validate/src/test/resources/org/aksw/rdfunit/validate/data/owl/ontology.ttl +++ b/rdfunit-validate/src/test/resources/org/aksw/rdfunit/validate/data/owl/ontology.ttl @@ -121,4 +121,12 @@ ex:CardMax2Class owl:onProperty ex:cardMax2 ; owl:maxCardinality "2"^^xsd:nonNegativeInteger ] ; - . \ No newline at end of file + . + +############################ +### Literals / Datatypes ### +############################ + +# rdf:langString +ex:langStringProperty a rdf:property ; + rdfs:range rdf:langString . \ No newline at end of file