Skip to content

Commit

Permalink
update test cases and shapes (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaria committed Feb 21, 2024
1 parent f5dff0b commit d961d96
Show file tree
Hide file tree
Showing 16 changed files with 459 additions and 23 deletions.
2 changes: 1 addition & 1 deletion ontology/documentation/ontology.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


<http://w3id.org/rml/lv/> a owl:Ontology ;
# TODO check https://github.com/kg-construct/rml-core/issues/73 for resolution
# check https://github.com/kg-construct/rml-core/issues/73 for resolution
# owl:imports <http://w3id.org/rml/core> ; # TODO not dereferencable?
owl:imports <https://raw.githubusercontent.com/kg-construct/rml-core/main/ontology/rml-core.owl> ;
# owl:imports <http://w3id.org/rml/io/> ; # TODO not dereferencable?
Expand Down
63 changes: 58 additions & 5 deletions shapes/lv.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,54 @@
rmlsh:LogicalViewShape a sh:NodeShape ;
sh:name "LogicalView" ;
sh:description """
A logical view is ...
A logical view (rml:LogicalView) is a type of logical source that is derived from another logical source by defining field with data from said logical source.
""" ;
sh:message """
Logical view requires ...
rml:LogicalView requires requires
- exactly one rml:source property, with a rml:LogicalSource as its value.
- at least one rml:field property, with a rml:Field as its value.
""" ;
sh:targetClass rml:LogicalView ;
sh:targetObjectsOf rml:parentLogicalView ;
sh:property [
sh:description """
TODO describe here and in spec
The source of the logical view. This is the logical source from which the logical view is derived.
""" ;
sh:message """
Exactly one rml:onLogicalSource property must be present, with a rml:LogicalSource as its value.
Exactly one rml:source property must be specified for a rml:LogicalView, with a rml:LogicalSource as its value.
""" ;
sh:path rml:source ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:node rmlsh:LogicalSource ;
sh:nodeKind sh:BlankNodeOrIRI ;
] , [
sh:description """
A field of the logical view.
""" ;
sh:message """
At least one rml:field property must be specified for a rml:LogicalView, with a resource as its value.
""" ;
sh:path rml:field ;
sh:minCount 1 ;
sh:nodeKind sh:BlankNodeOrIRI ;
] , [
sh:path [ sh:alternativePath ( rml:leftJoin rml:innerJoin ) ] ;
sh:description """
A left join of the logical view.
""" ;
sh:message """
The value of a rml:leftJoin property for a rml:LogicalView must be a resource.
""" ;
sh:path rml:leftJoin ;
sh:nodeKind sh:BlankNodeOrIRI ;
] , [
sh:description """
An inner join of the logical view.
""" ;
sh:message """
The value of a rml:innerJoin property for a rml:LogicalView must be a resource.
""" ;
sh:path rml:innerJoin ;
sh:nodeKind sh:BlankNodeOrIRI ;
] .

Expand All @@ -53,12 +76,24 @@ rmlsh:FieldShape a sh:NodeShape ;
sh:targetClass rml:Field ;
sh:targetObjectOf rml:field ;
sh:property [
sh:description """
The name of the field.
""" ;
sh:message """
Exactly one rml:fieldName property must be specified for a rml:Field, with a string as its value.
""" ;
sh:path rml:fieldName ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:datatype xsd:string ;
sh:nodeKind sh:Literal ;
] , [
sh:description """
A child field of the field.
""" ;
sh:message """
The value of a rml:field property for a rml:Field must be a resource.
""" ;
sh:path rml:field ;
sh:nodeKind sh:BlankNodeOrIRI ;
] .
Expand All @@ -75,15 +110,33 @@ rmlsh:LogicalViewJoinShape a sh:NodeShape ;
sh:targetClass rml:LogicalViewJoin ;
sh:targetObjectOf rml:leftJoin , rml:innerJoin ;
sh:property [
sh:description """
The parent logical view of the logical view join.
""" ;
sh:message """
Exactly one rml:parentLogicalView property must be specified for a rml:LogicalViewJoin, with a resource as its value.
""" ;
sh:path rml:parentLogicalView ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:nodeKind sh:BlankNodeOrIRI ;
] , [
sh:description """
A join condition of the logical view join.
""" ;
sh:message """
At least one rml:parentLogicalView property must be specified for a rml:LogicalViewJoin, with a resource as its value.
""" ;
sh:path rml:joinCondition ;
sh:minCount 1 ;
sh:nodeKind sh:BlankNodeOrIRI ;
] , [
sh:description """
A join condition of the logical view join.
""" ;
sh:message """
At least one rml:field property must be specified for a rml:LogicalViewJoin, with a resource as its value.
""" ;
sh:path rml:field ;
sh:minCount 1 ;
sh:nodeKind sh:BlankNodeOrIRI ;
Expand Down
9 changes: 9 additions & 0 deletions spec/section/joins.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ The logical iterations from the child logical view are extended with values from
When more than one logical iteration in the parent logical view matches with a logical iteration in the child logical view, each match leads to an additional extended logical iteration.
If no match is found for a logical iteration, the logical iteration is removed from the child logical view.

<aside class="issue">
Pano: If there are more than one join, what is the order of execution?
</aside>

### Join examples
<aside class="issue">
Pano please verify what I did with the iterator and # key from the parent logical view. Is this ok? This should still be described somewhere?
Expand Down Expand Up @@ -201,6 +205,11 @@ If an inner joins would have been used, the logical view would have only 3 logic
</aside>
</aside>

<aside class="issue">
We cannot just use the term `parent.#` as a field, since there may be multiple parents and `parent` could also be a declared field.
Do we need this as a field at all?
</aside>

### Inner join
<aside class=example id=ex-innerjoin>

Expand Down
17 changes: 11 additions & 6 deletions test-cases/RMLLVTC0001/mapping.ttl
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
@prefix rml: <http://w3id.org/rml/> .
@prefix : <http://example.org/> .

@base <http://example.com/base/> .

:jsonSource a rml:LogicalSource ;
rml:source [
a rml:RelativePathSource , rml:Source ;
rml:root rml:MappingDirectory ;
rml:path "people.json" ;
] ;
rml:referenceFormulation rml:JSONPath ;
rml:iterator "$.people[*]" .
Expand All @@ -16,11 +17,15 @@
rml:reference "$.name" ;
] .

# TODO
<#TriplesMap> a rml:TriplesMap ;
:triplesMapPerson a rml:TriplesMap ;
rml:logicalSource :jsonView ;
rml:subjectMap [
rml:constant :sub ;
rml:class :Any ;
rml:template "https://example.org/people/{name}" ;
] ;
rml:predicateObjectMap [
rml:predicate :hasName ;
rml:objectMap [
rml:reference "name" ;
] ;
] .

2 changes: 2 additions & 0 deletions test-cases/RMLLVTC0001/output.nq
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<http://example.org/people/alice> <http://example.org/hasName> "alice" .
<http://example.org/people/bob> <http://example.org/hasName> "bob" .
8 changes: 5 additions & 3 deletions test-cases/RMLLVTC0002/mapping.ttl
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
@prefix rml: <http://w3id.org/rml/> .
@prefix : <http://example.org/> .

@base <http://example.com/base/> .

:jsonSource a rml:LogicalSource ;
rml:source [] ; # TODO
rml:source [
a rml:RelativePathSource , rml:Source ;
rml:root rml:MappingDirectory ;
rml:path "people.json" ;
] ;
rml:referenceFormulation rml:JSONPath ;
rml:iterator "$.people[*]" .

Expand Down
60 changes: 52 additions & 8 deletions test-cases/RMLLVTC0003/mapping.ttl
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
@prefix rml: <http://w3id.org/rml/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix : <http://example.org/> .

@base <http://example.com/base/> .

:jsonSource a rml:LogicalSource ;
rml:source [] ; # TODO
rml:source [
a rml:RelativePathSource , rml:Source ;
rml:root rml:MappingDirectory ;
rml:path "people.json" ;
] ;
rml:referenceFormulation rml:JSONPath ;
rml:iterator "$.people[*]" .

Expand All @@ -28,7 +31,11 @@
] .

:csvSource a rml:LogicalSource ;
rml:source [] ; # TODO
rml:source [
a rml:RelativePathSource , rml:Source ;
rml:root rml:MappingDirectory ;
rml:path "people.csv" ;
] ;
rml:referenceFormulation rml:CSV .

:csvView a rml:LogicalView ;
Expand Down Expand Up @@ -57,10 +64,47 @@
] ;
] .

# TODO
<#TriplesMap> a rml:TriplesMap ;

:triplesMapPerson a rml:TriplesMap ;
rml:logicalSource :csvView ;
rml:subjectMap [
rml:template "http://example.org/person/{name}" ;
] ;
rml:predicateObjectMap [
rml:predicate :hasName ;
rml:objectMap [
rml:reference "name" ;
] ;
] ;
rml:predicateObjectMap [
rml:predicate :hasBirthyear ;
rml:objectMap [
rml:reference "birthyear" ;
rml:datatype xsd:gYear ;
] ;
] ;
rml:predicateObjectMap [
rml:predicate :hasItem ;
rml:objectMap [
rml:parentTriplesMap :triplesMapItem ;
] ;
] .

:triplesMapItem a rml:TriplesMap ;
rml:logicalSource :csvView ;
rml:subjectMap [
rml:constant :sub ;
rml:class :Any ;
rml:template "http://example.org/person/{name}/item/{item_type}" ;
] ;
rml:predicateObjectMap [
rml:predicate :hasType ;
rml:objectMap [
rml:reference "item_type" ;
] ;
] ;
rml:predicateObjectMap [
rml:predicate :hasWeight ;
rml:objectMap [
rml:reference "item_weight" ;
rml:datatype xsd:integer ;
] ;
] .
15 changes: 15 additions & 0 deletions test-cases/RMLLVTC0003/output.nq
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<http://example.org/people/alice> <http://example.org/hasName> "alice" .
<http://example.org/people/alice> <http://example.org/hasBirthyear> "1995"^^<http://www.w3.org/2001/XMLSchema#gYear> .
<http://example.org/people/alice> <http://example.org/hasItem> <http://example.org/people/alice/item/sword> .
<http://example.org/people/alice> <http://example.org/hasItem> <http://example.org/people/alice/item/shield> .
<http://example.org/people/alice/item/sword> <http://example.org/hasType> "sword" .
<http://example.org/people/alice/item/sword> <http://example.org/hasWeight> "1500"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://example.org/people/alice/item/shield> <http://example.org/hasType> "shield" .
<http://example.org/people/alice/item/shield> <http://example.org/hasWeight> "2500"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://example.org/people/bob> <http://example.org/hasName> "bob" .
<http://example.org/people/bob> <http://example.org/hasBirthyear> "1999"^^<http://www.w3.org/2001/XMLSchema#gYear> .
<http://example.org/people/bob> <http://example.org/hasItem> <http://example.org/people/alice/item/flower> .
<http://example.org/people/alice/item/flower> <http://example.org/hasType> "flower" .
<http://example.org/people/alice/item/flower> <http://example.org/hasWeight> "1500"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://example.org/people/tobias> <http://example.org/hasName> "tobias" .
<http://example.org/people/tobias> <http://example.org/hasBirthyear> "2005"^^<http://www.w3.org/2001/XMLSchema#gYear> .
Loading

0 comments on commit d961d96

Please sign in to comment.