Skip to content

Commit

Permalink
adding and correcting test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
elsdvlee committed Jul 20, 2024
1 parent 5932f97 commit 11d6845
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 28 deletions.
46 changes: 23 additions & 23 deletions spec/section/joins.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,21 @@ If an inner joins would have been used, the logical view would have only 3 logic
<tr>
<td>1</td>
<td>(row)</td>
<td>1</td>
<td>0</td>
<td>bob</td>
<td>1</td>
<td>0</td>
<td>1999</td>
<td>2</td>
<td>0</td>
<td>flower</td>
<td>2</td>
<td>0</td>
<td>15 </td>
</tr>
<tr>
<td>2</td>
<td>(row)</td>
<td>2</td>
<td>0</td>
<td>tobias</td>
<td>2</td>
<td>0</td>
<td>2005</td>
<td>null</td>
<td>null</td>
Expand Down Expand Up @@ -217,13 +217,13 @@ When an inner join is used, the resulting logical view has only 3 logical iterat
<tr>
<td>1</td>
<td>(row)</td>
<td>1</td>
<td>0</td>
<td>bob</td>
<td>1</td>
<td>0</td>
<td>1999</td>
<td>2</td>
<td>0</td>
<td>flower</td>
<td>2</td>
<td>0</td>
<td>15 </td>
</tr>
</table>
Expand All @@ -241,9 +241,9 @@ In this example a second [=logical view join=] is added to the [=logical view=]

```csv
name,id
alice,1
bob,2
tobias,3
alice,123
bob,456
tobias,789
```
</aside>

Expand Down Expand Up @@ -329,7 +329,7 @@ tobias,3
<td>0</td>
<td>1500 </td>
<td>0</td>
<td>1</td>
<td>123</td>
</tr>
<tr>
<td>0</td>
Expand All @@ -343,35 +343,35 @@ tobias,3
<td>1</td>
<td>2500 </td>
<td>0</td>
<td>1</td>
<td>123</td>
</tr>
<tr>
<td>1</td>
<td>(row)</td>
<td>1</td>
<td>0</td>
<td>bob</td>
<td>1</td>
<td>0</td>
<td>1999</td>
<td>2</td>
<td>0</td>
<td>flower</td>
<td>2</td>
<td>0</td>
<td>15 </td>
<td>0</td>
<td>2</td>
<td>456</td>
</tr>
<tr>
<td>2</td>
<td>(row)</td>
<td>2</td>
<td>0</td>
<td>tobias</td>
<td>2</td>
<td>0</td>
<td>2005</td>
<td>null</td>
<td>null</td>
<td>null</td>
<td>null </td>
<td>0</td>
<td>3</td>
<td>789</td>
</tr>
</table>

Expand Down
10 changes: 5 additions & 5 deletions spec/section/problem.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ It is not possible to declare the construction of below output triples from belo

```csv
name,id
alice,1
bob,2
tobias,3
alice,123
bob,456
tobias,789
```
</aside>

Expand All @@ -120,8 +120,8 @@ bob,flower
<aside class="ex-output">

```turtle
:person/1 :hasItem "sword", "shield" .
:person/2 :hasItem "flower" .
:person/123 :hasItem "sword", "shield" .
:person/456 :hasItem "flower" .
```
</aside>
</aside>
141 changes: 141 additions & 0 deletions test-cases/RMLLVTC0009/mapping.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
@prefix rml: <http://w3id.org/rml/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix : <http://example.org/> .

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

:jsonView a rml:LogicalView ;
rml:viewOn :jsonSource ;
rml:field [
rml:fieldName "name" ;
rml:reference "$.name" ;
] ;
rml:field [
rml:fieldName "item" ;
rml:reference "$.items[*]" ;
rml:field [
rml:fieldName "type" ;
rml:reference "$.type" ;
] ;
rml:field [
rml:fieldName "weight" ;
rml:reference "$.weight" ;
] ;
] .

:additionalCsvSource a rml:InputLogicalSource ;
rml:source [
a rml:RelativePathSource , rml:Source ;
rml:root rml:MappingDirectory ;
rml:path "people2.csv" ;
] ;
rml:referenceFormulation rml:CSV .

:additionalCsvView a rml:LogicalView ;
rml:viewOn :csvSource ;
rml:field [
rml:fieldName "name" ;
rml:reference "name" ;
] ;
rml:field [
rml:fieldName "id" ;
rml:reference "idr" ;
] ;
.

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

:csvView a rml:LogicalView ;
rml:viewOn :csvSource ;
rml:field [
rml:fieldName "name" ;
rml:reference "name" ;
] ;
rml:field [
rml:fieldName "birthyear" ;
rml:reference "birthyear" ;
] ;
rml:leftJoin [
rml:parentLogicalView :jsonView ;
rml:joinCondition [
rml:parent "name" ;
rml:child "name" ;
] ;
rml:field [
rml:fieldName "item_type" ;
rml:reference "item.type" ;
] ;
rml:field [
rml:fieldName "item_weight" ;
rml:reference "item.weight" ;
] ;
] ;
rml:leftJoin [
rml:parentLogicalView :addionalCsvView ;
rml:joinCondition [
rml:parent "name" ;
rml:child "name" ;
] ;
rml:field [
rml:fieldName "id" ;
rml:reference "id" ;
] ;
] .

:triplesMapPerson a rml:TriplesMap ;
rml:logicalSource :csvView ;
rml:subjectMap [
rml:template "http://example.org/person/{id}" ;
] ;
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:template "item_{#}_{item_type.#}" ;
rml:termType rml:BlankNode ;
] ;
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/RMLLVTC0009/output.nq
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<http://example.org/people/123> <http://example.org/hasName> "alice" .
<http://example.org/people/123> <http://example.org/hasBirthyear> "1995"^^<http://www.w3.org/2001/XMLSchema#gYear> .
<http://example.org/people/123> <http://example.org/hasItem> _:item_0_0 .
<http://example.org/people/123> <http://example.org/hasItem> _:item_0_1 .
_:item_0_0 <http://example.org/hasType> "sword" .
_:item_0_0 <http://example.org/hasWeight> "1500"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:item_0_1 <http://example.org/hasType> "shield" .
_:item_0_1 <http://example.org/hasWeight> "2500"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://example.org/people/456> <http://example.org/hasName> "bob" .
<http://example.org/people/456> <http://example.org/hasBirthyear> "1999"^^<http://www.w3.org/2001/XMLSchema#gYear> .
<http://example.org/people/456> <http://example.org/hasItem> _:item_1_2 .
_:item_1_2 <http://example.org/hasType> "flower" .
_:item_1_2 <http://example.org/hasWeight> "1500"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://example.org/person/789> <http://example.org/hasName> "tobias" .
<http://example.org/person/789> <http://example.org/hasBirthyear> "2005"^^<http://www.w3.org/2001/XMLSchema#gYear> .
4 changes: 4 additions & 0 deletions test-cases/RMLLVTC0009/people.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name,birthyear
alice,1995
bob,1999
tobias,2005
26 changes: 26 additions & 0 deletions test-cases/RMLLVTC0009/people.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"people": [
{
"name": "alice",
"items": [
{
"type": "sword",
"weight": 1500
},
{
"type": "shield",
"weight": 2500
}
]
},
{
"name": "bob",
"items": [
{
"type": "flower",
"weight": 15
}
]
}
]
}
4 changes: 4 additions & 0 deletions test-cases/RMLLVTC0009/people2.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name,id
alice,123
bob,456
tobias,789

0 comments on commit 11d6845

Please sign in to comment.