(1) Create turtle data:
@prefix dbr: <http://dbpedia.org/resource/> .
@prefix : <http://example.org/> .
dbr:Vibeke :member-of dbr:Tristania .
dbr:Morten :member-of dbr:Tristania .
dbr:Tristania :genre dbr:Metal .
:author1 :cites :author1 .
:author2 :cites :author1 .
:author2 :cites :author2 .
(2) Load data into Blazegraph with a sparql update.
(2) Find all distinct predicates
SELECT DISTINCT ?p
WHERE { ?s ?p ?o . }
<http://example.org/cites>
<http://example.org/genre>
<http://example.org/member-of>
(2a.r) Select the subjects as rows for :member-of
SELECT ?s
WHERE { ?s <http://example.org/member-of> ?o . }
s
<http://dbpedia.org/resource/Morten> === > 2
<http://dbpedia.org/resource/Vibeke> === > 1
Check:
Matches 1-rows in tiny-mixed-example:
1 2
(2a.c) Select the objects as columns for :member-of
SELECT ?o
WHERE { ?s <http://example.org/member-of> ?o . }
<http://dbpedia.org/resource/Tristania> === > 0
<http://dbpedia.org/resource/Tristania> === > 0
Check:
Matches 1-cols in tiny-mixed-example:
0 0
(2b.r) Select the subjects as rows for :genre
SELECT ?s
WHERE { ?s <http://example.org/genre> ?o . }
<http://dbpedia.org/resource/Tristania> ==> 0
Check:
Matches 2-rows in tiny-mixed-example:
0
(2b.c) Select the objects as rows for :genre
SELECT ?o
WHERE { ?s <http://example.org/genre> ?o . }
<http://dbpedia.org/resource/Metal> ==> 3
Check:
Matches 2-cols in tiny-mixed-example:
0
(2c.r) Select the subjects as rows for :cites
SELECT ?s
WHERE { ?s <http://example.org/cites> ?o . }
<http://example.org/author1> ==> 4
<http://example.org/author2> ==> 5
<http://example.org/author2> ==> 5
Check:
Matches 3-rows in tiny-mixed-example:
4 5 5
(2c.c) Select the objects as rows for :cites
SELECT ?o
WHERE { ?s <http://example.org/cites> ?o . }
<http://example.org/author1> ==> 4
<http://example.org/author1> ==> 4
<http://example.org/author2> ==> 5
Check:
Matches 3-cols in tiny-mixed-example:
4 4 5
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment