Skip to content

Commit

Permalink
full support for rdf:langString (with tests) fixes #21
Browse files Browse the repository at this point in the history
  • Loading branch information
jimkont committed Aug 27, 2014
1 parent 7c358f5 commit 15cbb49
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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#") ).
Expand All @@ -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 ;
Expand Down
44 changes: 44 additions & 0 deletions rdfunit-core/src/main/resources/org/aksw/rdfunit/patterns.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@prefix ex: <http://example.com/ns#> .

@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:langStringProperty
"asdf"@en ,
"asdf"@de ,
"sdfg"@it .
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@prefix ex: <http://example.com/ns#> .

@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:langStringProperty
"asdf" , # 1 error
"asdf"@de ,
"sdfg"@it ,
ex:someValue . # 1 error (checked with isLiteral generator)
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,12 @@ ex:CardMax2Class
owl:onProperty ex:cardMax2 ;
owl:maxCardinality "2"^^xsd:nonNegativeInteger
] ;
.
.

############################
### Literals / Datatypes ###
############################

# rdf:langString
ex:langStringProperty a rdf:property ;
rdfs:range rdf:langString .

0 comments on commit 15cbb49

Please sign in to comment.