Tarje Sælen Lavik
Digitale systemer og tjenester, UBB
goo.gl/vvQtY4
Sparql
Kræsjkurs i spørringer på data i piloten
Sparql...
... Protocol and RDF Query Language
- 4 typer spørringer...
- WHERE for å begrense resultatsettet
- FILTER, ORDER, JOIN, SORT, AGGREGATE
- GRAPH for "containers"
- SERVICE for samlet søk
Tripler og prefix
Tripel
<http://ex.org/Book1> a bibo:Book ; <http://purl.org/dc/terms/title> "Boka" .
Med prefix
prefix ex: <http://ex.org/Book1> prefix dct: <http://purl.org/dc/terms/>
prefix bibo: <http://purl.org/ontology/bibo/> ex:Book1 a bibo:Book ; dct:title "Boka" .
SELECT
SELECT *
WHERE
{ ?s ?p ?o }
LIMIT 1
?s | ?p | ?o |
---|---|---|
ex:Book1 | a | "Bibliographic" |
ASK
ASK
WHERE
{ ?bok a bibo:Book }
false
ASK
prefix bs: <http://livedata.bibsys.no/>
ASK
WHERE
{ ?bok bs:format "Bok" }
true
CONSTRUCT
prefix bs: <http://livedata.bibsys.no/>
prefix bibo: <http://purl.org/ontology/bibo/>
CONSTRUCT { ?s a bibo:Book } WHERE { ?s bs:format "Bok" }
ex:Book1 a bibo:Book
DESCRIBE
DESCRIBE <http://livedata.bibsys.no/biblio/900563966>
<http://livedata.bibsys.no/biblio/900563966>
a "Bibliographic" ;
<http://livedata.bibsys.no/dewey> "220.8" ;
<http://livedata.bibsys.no/format> "Bok" ;
<http://livedata.bibsys.no/hovedordningsord> "Frisak, Astri" ;
<http://purl.org/ontology/bibo/numPages> "123" ;
dc:title "Plantene i Bibelen :med legender, myter og sagn" ;
dc:creator <http://livedata.bibsys.no/authority/90820071> ;
dc:subject "bibelen" , "botanikk" ;
<http://schema.org/sameAs> <http://www.oria.no/?sokeindeks=lsr09&search=900563966> .
Finne bestand
location |
total |
---|---|
NB |
5902101 |
UBO |
3199317 |
UBB |
1965228 |
prefix fabio: <http://purl.org/spar/fabio/>
prefix bs: <http://livedata.bibsys.no/>
SELECT DISTINCT
?location (COUNT(?holding) AS ?total)
WHERE {
?holding bs:location ?location .
}
GROUP BY ?location
UBBs samlinger
ubbcol |
total |
---|---|
1120108 |
164748 |
1120100 |
775501 |
1120103 |
147477 |
1120104 |
274659 |
1120106 |
173709 |
1120107 |
88534 |
UBB |
5971 |
1120101 |
35657 |
1120109 |
66899 |
1120119 |
232073 |
prefix fabio: <http://purl.org/spar/fabio/>
prefix bs: <http://livedata.bibsys.no/>
SELECT DISTINCT
?ubbcol (COUNT(?holding) AS ?total)
WHERE {
?holding bs:location "UBB" ;
bs:collection ?ubbcol .
}
GROUP BY ?ubbcol
UBBSPES
UBBSPES bestand
prefix fabio: <http://purl.org/spar/fabio/>
prefix bs: <http://livedata.bibsys.no/>
SELECT
?biblio ?title
WHERE {
?holding bs:collection "1120109" ;
fabio:isManifestationOf ?biblio .
?biblio dc:title ?title .
}
GROUP BY ?title ?biblio
ORDER BY ?title
biblio |
title |
---|---|
"1864" i Billeder og Text |
|
"Aandelige klenodier" :spelstykkje i tri akter |
|
"Absolut Sikkerhed" :en Fortælling |
|
"Aftenpostens" kart over krigsskuepladsen |
|
"Ah!" :Farce |
|
"Bedre frem Bergen-" :Bergens næringsliv 1845-1995 |
|
"De har en datter" :lystspil i een akt |
|
"Den Constitutionelle" red.: Carl Fougstad, U.A. Motzfeldt, A. Schweigaard opfordrer stiftamtmand Christie at yde bidrag |
|
"Den første Gang" :Prolog til Henr. Wergeland's første Stykke paa Kristianias offentlige Theater, Syngestykket "Cambellerne, eller Den den hjemkomne Søn" |
|
"Den glade gauk" :25 aars beretning : [Frimurernes sangforenings orden i Bergen] |
|
"Den politiske Situation" og de Christne |
|
"Den tredje" :bemærkninger til Ibsens "Kejser og Galilæer" |
|
"Den tredje" :bemærkninger til Ibsens "Kejser og Galilæer" |
Kortfattet jordbes...
prefix fabio: <http://purl.org/spar/fabio/>
DESCRIBE ?biblio ?holding
WHERE {
?biblio dc:title "Kortfattet jordbeskrivelse eller
geographie til brug i landsbyskolerne" .
?holding fabio:isManifestationOf ?biblio .
}
subject |
predicate |
object |
---|---|---|
Bok |
||
Storm, Edvard |
||
1792 |
||
35 |
||
København |
||
NO-TrBIB |
||
Bibliographic |
||
Kortfattet jordbeskrivelse eller geographie til brug i landsbyskolerne |
||
020505655 |
||
0 |
||
2015-11-05 |
||
1120109 |
||
UBB |
||
d00180 |
||
0 |
||
Holdings |
Hva er Marcus?
Spesialsamlingenes nye fellesløsning både for registrering og formidling av spesialsamlinger.
- Basert på lenkede data
- Henter data fra mange kilder
<http://data.ub.uib.no/instance/photograph/ubb-kk-n-518-041> a <http://data.ub.uib.no/ontology/Photograph> ; <http://data.ub.uib.no/ontology/cataloguer> <http://data.ub.uib.no/Cataloguer_4> ; <http://data.ub.uib.no/ontology/hasRepresentation> <http://data.ub.uib.no/instance/aggregation/ubb-kk-n-518-041> ; <http://data.ub.uib.no/ontology/hasThumbnail> "http://data.ub.uib.no/files/bs/ubb/ubb-kk/ubb-kk-n/ubb-kk-n-518/ubb-kk-n-518-041/jpg/ubb-kk-n-518-041_th.jpg"^^<http://www.w3.org/2001/XMLSchema#anyuri> ; <http://data.ub.uib.no/ontology/showWeb> true ; <http://purl.org/NET/c4dm/event.owl#producedIn> <http://data.ub.uib.no/instance/event/63d92c7d-74c9-4087-9969-af053f3fe1ee> ; <http://purl.org/dc/terms/available> "2014-08-19"^^<http://www.w3.org/2001/XMLSchema#date> ; <http://purl.org/dc/terms/created> "1922"^^<http://www.w3.org/2001/XMLSchema#gYear> ; <http://purl.org/dc/terms/identifier> "ubb-kk-n-518-041"^^<http://www.w3.org/2001/XMLSchema#string> ; <http://purl.org/dc/terms/isPartOf> <http://data.ub.uib.no/instance/collection/ubb-kk-n> ; <http://purl.org/dc/terms/spatial> <http://data.ub.uib.no/instance/spatialthing/959d4dca-8d38-46f4-8962-1d0c7c94688a> , <http://data.ub.uib.no/instance/spatialthing/cf717543-2ee5-48c6-9b83-016a16aedddc> ; <http://purl.org/dc/terms/subject> <http://data.ub.uib.no/topic/7b2d2fa6-73f5-4075-b394-20e64aa5fb54> , <http://data.ub.uib.no/topic/5a098fbd-c3dd-431d-a77e-5fc533081335> , <http://data.ub.uib.no/topic/bf4f6df5-05f7-4f0e-93ea-f1f1917a675a> , <http://data.ub.uib.no/topic/8a98f33f-8d85-461c-ad33-c248106bba07> , <http://data.ub.uib.no/topic/7d2b9388-8eba-4a4a-b72b-ab15c5c820e8> , <http://data.ub.uib.no/topic/f4086d26-fdcd-4d35-bbef-dc862ada345e> , <http://data.ub.uib.no/topic/f0c29c87-d2d5-4362-92b3-a6aa275d801d> ; <http://purl.org/dc/terms/title> "10de. nationale landsturnstevne i Bergen, juni 1922"^^<http://www.w3.org/2001/XMLSchema#string> ; <http://xmlns.com/foaf/0.1/maker> <http://data.ub.uib.no/instance/company/0d52fbb1-4cdd-4fae-8e5f-cc680f6764fe> .
Hvordan sy sammen data
"Signaturen"
ubb-romertall-oktav-xii-1820
952668661
ubb-romertall-oktav-xii-1820
URI
<http://data.ub.uib.no/instance/book/ubb-romertall-oktav-xii-1820>
<https://livedata.bibsys.no/biblio/952668661>
<http://data.ub.uib.no/instance/aggregation/ubb-romertall-oktav-xii-1820>
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#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX bibo: <http://purl.org/ontology/bibo/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX ubbont: <http://data.ub.uib.no/ontology/>
CONSTRUCT
{ <http://data.ub.uib.no/instance/book/ubb-romertall-oktav-xii-1820> ?p ?o .
<http://data.ub.uib.no/instance/book/ubb-romertall-oktav-xii-1820> owl:sameAs ?biblio .}
WHERE
{ GRAPH ?G
{ <http://data.ub.uib.no/instance/book/ubb-romertall-oktav-xii-1820> ?p ?o
OPTIONAL
{ <http://data.ub.uib.no/instance/book/ubb-romertall-oktav-xii-1820> ubbont:bibsysID ?bibsysId
SERVICE <http://pallas.bibsys.no:9999/blazegraph/namespace/metadata/sparql> {
?biblio dc:identifier ?bibsysId . }
}
}
}
Binde alt sammen
@prefix dct: <http://purl.org/dc/terms/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix ubbont: <http://data.ub.uib.no/ontology/> .
@prefix bibo: <http://purl.org/ontology/bibo/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
<http://data.ub.uib.no/instance/book/ubb-romertall-oktav-xii-1820>
a bibo:Book ;
ubbont:bibsysID "952668661" ;
ubbont:cataloguer <http://data.ub.uib.no/Cataloguer_3> ;
ubbont:hasRepresentation <http://data.ub.uib.no/instance/aggregation/ubb-romertall-oktav-xii-1820> ;
ubbont:hasThumbnail "http://data.ub.uib.no/files/manlib/ubb/ubb-romertall/ubb-romertall-oktav/ubb-romertall-oktav-xii/ubb-romertall-oktav-xii-1820/jpg/ubb-romertall-oktav-xii-1820_p0001_th.jpg"^^<http://www.w3.org/2001/XMLSchema#anyuri> ;
dct:available "2016-03-07"^^<http://www.w3.org/2001/XMLSchema#date> ;
dct:identifier "ubb-romertall-oktav-xii-1820" ;
dct:isPartOf <http://data.ub.uib.no/instance/collection/ubb-romertall> ;
dct:title "Professor I.C. Fabricius's Reise igjennem Norge i Aaret 1778 :med Anmerkninger over Naturhistorie og Oeconomie" ;
bibo:pages 231 ;
owl:sameAs <http://livedata.bibsys.no/biblio/952668661> .
Konklusjon!
- SPARQL er en standard "API"
- Bruker http
- Mulig å hente ut akkurat det du trenger
- På det formatet du foretrekker
- Ikke nødvendig å være enig om datamodell på forhånd
Besøk marcus.uib.no
Spørsmål eller kommentarer?
tarje.lavik@ub.uib.no
#tarjelavik
slides.com/tarjelavik/semweb2016-sparql
TIF File by mantisshrimpdesign from the Noun Project
Folder by Jevgeni Striganov from the Noun Project
JPG File by Chameleon Design from the Noun Project
XML File by mantisshrimpdesign from the Noun Project
SPARQL semweb 2016
By Tarje Lavik
SPARQL semweb 2016
Workshop 14. mars 2016
- 1,190