Skip to content

Commit

Permalink
dsp:languageOccurrence #22
Browse files Browse the repository at this point in the history
  • Loading branch information
jimkont committed Sep 9, 2014
1 parent 22d1a8d commit ac02c75
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,51 @@ rutg:DSPRANGEC-MISS a rut:TestGenerator ;
# TODO dsp:subPropertyOf
# TODO dsp:vocabularyEncodingScheme
# TODO dsp:literalConstraint -> dsp:literal
# TODO dsp:literalConstraint -> dsp:languageOccurrence

##########################################
# dsp:literalConstraint -> dsp:languageOccurrence => "mandatory" / "optional" / "disallowed"
##########################################

# TODO make pattern for lang in domain

# no domain check mandatory
rutg:DSPLANG-OC 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 ('=' as ?OP) ('' as ?V1) ?DESCRIPTION where {
?s a dsp:DescriptionTemplate .
?s dsp:statementTemplate/dsp:property ?P1 .
?s dsp:statementTemplate/dsp:literalConstraint/dsp:languageOccurrence ?lang .
FILTER NOT EXISTS {?s dsp:resourceClass ?x}
FILTER ( str(?lang) = "mandatory" )
BIND (concat(str(?P1)," does not have language defined") AS ?DESCRIPTION)} """ ;
rut:basedOnPattern rutp:CHECKLANG ;
rut:resultAnnotation [
a rut:ResultAnnotation ;
rut:annotationProperty rlog:level ;
rut:annotationValue rlog:ERROR] ;
.

# no domain check disallowed
rutg:DSPLANG-OC 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 ('=' as ?OP) ('' as ?V1) ?DESCRIPTION where {
?s a dsp:DescriptionTemplate .
?s dsp:statementTemplate/dsp:property ?P1 .
?s dsp:statementTemplate/dsp:literalConstraint/dsp:languageOccurrence ?lang .
FILTER NOT EXISTS {?s dsp:resourceClass ?x}
FILTER ( str(?lang) = "disallowed" )
BIND (concat(str(?P1)," language is disallowed") AS ?DESCRIPTION)} """ ;
rut:basedOnPattern rutp:CHECKLANG ;
rut:resultAnnotation [
a rut:ResultAnnotation ;
rut:annotationProperty rlog:level ;
rut:annotationValue rlog:ERROR] ;
.


# TODO dsp:literalConstraint -> dsp:language
# TODO dsp:literalConstraint -> dsp:syntaxEncodingSchemeOccurrence
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public void setUp() throws Exception {
testsWithErrors.put("dsp/valueClass_Correct.ttl", 0);
testsWithErrors.put("dsp/valueClass_Wrong.ttl", 1);
testsWithErrors.put("dsp/valueClass-miss_Wrong.ttl", 1);
testsWithErrors.put("dsp/languageOccurrence_Correct.ttl", 0);
testsWithErrors.put("dsp/languageOccurrence_Wrong.ttl", 2); // TODO 4

// Resource Shapes
testsWithErrors.put("rs/valueType_Correct.ttl", 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,66 @@ exdsp:DSPPropCard_x_0
# dsp:ValueClass (range)

exdsp:DSPValueClass
a dsp:DescriptionTemplate ;
dsp:statementTemplate [
a dsp:NonLiteralStatementTemplate ;
dsp:property exdsp:PropValueClass ;
dsp:nonLiteralConstraint [
a dsp:NonLiteralConstraint ;
dsp:valueClass exdsp:ValueClassClass ;
]
a dsp:DescriptionTemplate ;
dsp:statementTemplate [
a dsp:NonLiteralStatementTemplate ;
dsp:property exdsp:PropValueClass ;
dsp:nonLiteralConstraint [
a dsp:NonLiteralConstraint ;
dsp:valueClass exdsp:ValueClassClass ;
]
]
.

##############
# dsp:languageOccurrence ("mandatory" / "optional" / "disallowed")

exdsp:languageOccurrenceMandatoryTemplate
a dsp:DescriptionTemplate ;
dsp:resourceClass exdsp:languageOccurrenceMandatoryClass ;
dsp:statementTemplate [
a dsp:LiteralStatementTemplate ;
dsp:property exdsp:languageOccurrenceMandatoryProp ;
dsp:literalConstraint [
a dsp:LiteralConstraint ;
dsp:languageOccurrence "mandatory"^^dsp:occurrence ;
]
]
.

exdsp:languageOccurrenceMandatoryTemplateSA # standalone (without class)
a dsp:DescriptionTemplate ;
dsp:statementTemplate [
a dsp:LiteralStatementTemplate ;
dsp:property exdsp:languageOccurrenceMandatoryPropSA ;
dsp:literalConstraint [
a dsp:LiteralConstraint ;
dsp:languageOccurrence "mandatory"^^dsp:occurrence ;
]
]
.

exdsp:languageOccurrenceDisallowedTemplate
a dsp:DescriptionTemplate ;
dsp:resourceClass exdsp:languageOccurrenceDisallowedClass ;
dsp:statementTemplate [
a dsp:LiteralStatementTemplate ;
dsp:property exdsp:languageOccurrenceDisallowedProp ;
dsp:literalConstraint [
a dsp:LiteralConstraint ;
dsp:languageOccurrence "disallowed"^^dsp:occurrence ;
]
]
.

exdsp:languageOccurrenceDisallowedTemplateSA # Standalone
a dsp:DescriptionTemplate ;
dsp:statementTemplate [
a dsp:LiteralStatementTemplate ;
dsp:property exdsp:languageOccurrenceDisallowedPropSA ;
dsp:literalConstraint [
a dsp:LiteralConstraint ;
dsp:languageOccurrence "disallowed"^^dsp:occurrence ;
]
]
.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@prefix exdsp: <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

exdsp:correct1 a exdsp:languageOccurrenceMandatoryClass ;
exdsp:languageOccurrenceMandatoryProp "value"@en .

exdsp:correct2 exdsp:languageOccurrenceMandatoryPropSA "value"@en .

exdsp:correct3 a exdsp:languageOccurrenceDisallowedClass ;
exdsp:languageOccurrenceDisallowedProp "value" .

exdsp:correct4 exdsp:languageOccurrenceDisallowedPropSA "value"@en .
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@prefix exdsp: <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

exdsp:correct1 a exdsp:languageOccurrenceMandatoryClass ;
exdsp:languageOccurrenceMandatoryProp "value" . # 1 error

exdsp:correct2 exdsp:languageOccurrenceMandatoryPropSA "value" . # 1 error

exdsp:correct3 a exdsp:languageOccurrenceDisallowedClass ;
exdsp:languageOccurrenceDisallowedProp "value"@it . # 1 error

exdsp:correct4 exdsp:languageOccurrenceDisallowedPropSA "value" . # 1 error

0 comments on commit ac02c75

Please sign in to comment.