Skip to content

Commit 1f4c640

Browse files
committed
head to head
1 parent b7fc102 commit 1f4c640

File tree

6 files changed

+127
-64
lines changed

6 files changed

+127
-64
lines changed

json2rdf_and_sparql/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
all:
2+
docker build -t justin2004/rml-testing-jena .
3+
cat ../characters.json | docker run --rm -i atomgraph/json2rdf 'http://tmp.com/' > characters.raw.ttl && docker run -v `pwd`:/mnt --rm -i justin2004/rml-testing-jena ./apache-jena-3.17.0/bin/sparql --data=/mnt/characters.raw.ttl --query=/mnt/query.sparql > out.ttl

json2rdf_and_sparql/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## using json2rdf + sparql
2+
3+
- have make and docker installed
4+
- `make`
5+
6+
and then find `out.ttl`

json2rdf_and_sparql/out.ttl

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@prefix ex: <http://example.com/> .
2+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
3+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
4+
@prefix tmp: <http://tmp.com/#> .
5+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
6+
@prefix sch: <http://schema.org/> .
7+
@prefix wd: <http://www.wikidata.org/entity/> .
8+
9+
[ a sch:Person ;
10+
sch:givenName "Misty" ;
11+
sch:owns [ a sch:Collection ;
12+
sch:hasPart [ sch:name "hair tie" ]
13+
] ;
14+
owl:sameAs wd:Q1057356
15+
] .
16+
17+
[ a sch:Person ;
18+
sch:familyName "Ketchum" ;
19+
sch:givenName "Ash" ;
20+
sch:owns [ a sch:Collection ;
21+
sch:hasPart [ sch:weight [ rdf:value "30"^^xsd:int ;
22+
ex:units ex:ounces
23+
]
24+
] ;
25+
sch:hasPart [ sch:name "sword" ;
26+
sch:weight [ rdf:value "400"^^xsd:int ;
27+
ex:units ex:ounces
28+
]
29+
] ;
30+
sch:hasPart [ sch:name "spoon" ] ;
31+
sch:hasPart [ a wd:Q169031 ;
32+
sch:name "gloves" ;
33+
sch:weight [ rdf:value "20"^^xsd:int ;
34+
ex:units ex:ounces
35+
]
36+
]
37+
]
38+
] .
39+
40+
[ a sch:Person ;
41+
sch:familyName "Mountain" ;
42+
sch:givenName "Misty" ;
43+
sch:owns [ a sch:Collection ;
44+
sch:hasPart [] ;
45+
sch:hasPart [ sch:name "gloves" ;
46+
sch:weight [ rdf:value "16"^^xsd:int ;
47+
ex:units ex:ounces
48+
]
49+
]
50+
]
51+
] .

rml/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
all:
22
docker build -t justin2004/rml-testing .
3+
cat ../characters.json | docker run --rm -i justin2004/rml-testing sbcl --script /root/addid.lisp > characters.pp.json
4+
docker run --rm -i -v `pwd`:/mnt justin2004/rml-testing java -jar /root/rmlmapper-java/target/rmlmapper-4.9.1-r326.jar -m mapping.rml.ttl > characters.nq && docker run -v `pwd`:/mnt --rm -i justin2004/rml-testing-jena ./apache-jena-3.17.0/bin/sparql --data=/mnt/characters.nq --query=/mnt/query.sparql > out.ttl

rml/README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
# rml usage with generic preprocessing
2+
3+
## how
4+
5+
- do json2rdf_and_sparql first then come back here
6+
7+
## prepare
8+
- have docker and make installed
9+
- `make`
10+
11+
then find `out.ttl`
12+
13+
14+
## notes
15+
216
"The case without a single identifier field for nested items in the child array is currently not possible with RML and JSONPath."
317
https://github.com/RMLio/rmlmapper-java/issues/93#issuecomment-771695761
418

@@ -14,14 +28,3 @@ what i like about this approach:
1428
- see the other notes at the top of mapping.rml.ttl
1529

1630

17-
## how
18-
19-
## prepare
20-
- have docker and make installed
21-
- `make`
22-
23-
### first preprocess (if necessary)
24-
`cat characters.json | docker run --rm -i justin2004/rml-testing sbcl --script /root/addid.lisp > characters.pp.json`
25-
26-
### then run the rml mapper
27-
`docker run --rm -i -v `pwd`:/mnt justin2004/rml-testing java -jar /root/rmlmapper-java/target/rmlmapper-4.9.1-r326.jar -m mapping.rml.ttl > characters.nq`

rml/out.ttl

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,56 @@
1-
[ a <http://schema.org/Person> ;
2-
<http://schema.org/has> [ a <http://schema.org/Collection> ;
3-
<http://schema.org/contains> [ <http://schema.org/name> "hair tie" ;
4-
<http://schema.org/weight> [ <http://example.org/rules/units>
5-
<http://example.org/rules/ounces> ]
6-
]
7-
] ;
8-
<http://schema.org/name> "Misty" ;
9-
<http://www.w3.org/2002/07/owl#sameAs>
10-
<http://www.wikidata.org/entity/Q1057356>
1+
@prefix ex: <http://example.com/> .
2+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
3+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
4+
@prefix tmp: <http://tmp.com/#> .
5+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
6+
@prefix sch: <http://schema.org/> .
7+
@prefix wd: <http://www.wikidata.org/entity/> .
8+
9+
[ a sch:Person ;
10+
sch:givenName "Misty" ;
11+
sch:owns [ a sch:Collection ;
12+
sch:hasPart [ sch:name "hair tie" ;
13+
sch:weight [ ex:units ex:ounces ]
14+
]
15+
] ;
16+
owl:sameAs wd:Q1057356
1117
] .
1218

13-
[ a <http://schema.org/Person> ;
14-
<http://schema.org/has> [ a <http://schema.org/Collection> ;
15-
<http://schema.org/contains> [ <http://schema.org/name> "sword" ;
16-
<http://schema.org/weight> [ <http://www.w3.org/1999/02/22-rdf-syntax-ns#value>
17-
"44400"^^<http://www.w3.org/2001/XMLSchema#int> ;
18-
<http://example.org/rules/units>
19-
<http://example.org/rules/ounces>
20-
]
21-
] ;
22-
<http://schema.org/contains> [ a <http://www.wikidata.org/entity/Q169031> ;
23-
<http://schema.org/name> "gloves" ;
24-
<http://schema.org/weight> [ <http://www.w3.org/1999/02/22-rdf-syntax-ns#value>
25-
"340"^^<http://www.w3.org/2001/XMLSchema#int> ;
26-
<http://example.org/rules/units>
27-
<http://example.org/rules/ounces>
28-
]
29-
] ;
30-
<http://schema.org/contains> [ <http://schema.org/name> "spoon" ;
31-
<http://schema.org/weight> [ <http://example.org/rules/units>
32-
<http://example.org/rules/ounces> ]
33-
] ;
34-
<http://schema.org/contains> [ <http://schema.org/weight> [ <http://www.w3.org/1999/02/22-rdf-syntax-ns#value>
35-
"1000"^^<http://www.w3.org/2001/XMLSchema#int> ;
36-
<http://example.org/rules/units>
37-
<http://example.org/rules/ounces>
38-
]
39-
]
40-
] ;
41-
<http://schema.org/name> "Ash"
19+
[ a sch:Person ;
20+
sch:familyName "Ketchum" ;
21+
sch:givenName "Ash" ;
22+
sch:owns [ a sch:Collection ;
23+
sch:hasPart [ sch:name "sword" ;
24+
sch:weight [ rdf:value "400"^^xsd:int ;
25+
ex:units ex:ounces
26+
]
27+
] ;
28+
sch:hasPart [ a wd:Q169031 ;
29+
sch:name "gloves" ;
30+
sch:weight [ rdf:value "20"^^xsd:int ;
31+
ex:units ex:ounces
32+
]
33+
] ;
34+
sch:hasPart [ sch:name "spoon" ;
35+
sch:weight [ ex:units ex:ounces ]
36+
] ;
37+
sch:hasPart [ sch:weight [ rdf:value "30"^^xsd:int ;
38+
ex:units ex:ounces
39+
]
40+
]
41+
]
4242
] .
4343

44-
[ a <http://schema.org/Person> ;
45-
<http://schema.org/has> [ a <http://schema.org/Collection> ;
46-
<http://schema.org/contains> [ <http://schema.org/weight> [ <http://example.org/rules/units>
47-
<http://example.org/rules/ounces> ]
48-
] ;
49-
<http://schema.org/contains> [ <http://schema.org/name> "gloves" ;
50-
<http://schema.org/weight> [ <http://www.w3.org/1999/02/22-rdf-syntax-ns#value>
51-
"340"^^<http://www.w3.org/2001/XMLSchema#int> ;
52-
<http://example.org/rules/units>
53-
<http://example.org/rules/ounces>
54-
]
55-
]
56-
] ;
57-
<http://schema.org/name> "Misty"
44+
[ a sch:Person ;
45+
sch:familyName "Mountain" ;
46+
sch:givenName "Misty" ;
47+
sch:owns [ a sch:Collection ;
48+
sch:hasPart [ sch:weight [ ex:units ex:ounces ]
49+
] ;
50+
sch:hasPart [ sch:name "gloves" ;
51+
sch:weight [ rdf:value "16"^^xsd:int ;
52+
ex:units ex:ounces
53+
]
54+
]
55+
]
5856
] .

0 commit comments

Comments
 (0)