More Related Content
Similar to Yokohama Art Spot meets SPARQL
Similar to Yokohama Art Spot meets SPARQL (20)
Yokohama Art Spot meets SPARQL
- 3. LODAC (Linked Open Data for ACademia)
✦ http://lod.ac
✦ Web
✦
✴ Linked Data(LOD)
✴
✴
✦
✴
✴ LODAC
- 5. LODAC Museum
✦
✴
✴
✴
✴ DBpedia Lite
✴ 15 → 70
✦ 13035604
✦ SPARQL http://lod.ac/sparql
- 11. Yokohama Art Spot
q_spt = """
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-
ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX omgeo: <http://www.ontotext.com/owlim/geo#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX lodac: <http://lod.ac/ns/lodac#>
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#>
SELECT distinct ?link ?title ?lat ?long ?postalcode ?
address ?access
WHERE {
?link rdf:type foaf:Organization;
rdfs:label ?title;
dc:references ?ref
.
?ref omgeo:within(%(NE_lat)s %(NE_long)s %(SW_lat)s
%(SW_long)s);
geo:lat ?lat;
geo:long ?long;
dc:source <http://place.yafjp.org/rdf/>;
vcard:postal-code ?postalcode;
<http://ocdi.jp/ns/pi#address> ?address
.
OPTIONAL{
?ref dc:abstract ?access
.
}
- 12. Step1
q_spt = """
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-
ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX omgeo: <http://www.ontotext.com/owlim/geo#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX lodac: <http://lod.ac/ns/lodac#>
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#>
SELECT distinct ?link ?title ?lat ?long ?postalcode ?
address ?access
WHERE {
?link rdf:type foaf:Organization;
rdfs:label ?title;
dc:references ?ref
.
?ref omgeo:within(%(NE_lat)s %(NE_long)s %(SW_lat)s
%(SW_long)s);
geo:lat ?lat;
geo:long ?long;
dc:source <http://place.yafjp.org/rdf/>;
vcard:postal-code ?postalcode;
<http://ocdi.jp/ns/pi#address> ?address
.
OPTIONAL{
?ref dc:abstract ?access
.
}
- 13. Step2 &
q_spt = """
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-
ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX omgeo: <http://www.ontotext.com/owlim/geo#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX lodac: <http://lod.ac/ns/lodac#>
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#>
SELECT distinct ?link ?title ?lat ?long ?postalcode ?
address ?access
WHERE {
?link rdf:type foaf:Organization;
rdfs:label ?title;
dc:references ?ref
.
?ref omgeo:within(%(NE_lat)s %(NE_long)s %(SW_lat)s
%(SW_long)s);
geo:lat ?lat;
geo:long ?long;
dc:source <http://place.yafjp.org/rdf/>;
vcard:postal-code ?postalcode;
<http://ocdi.jp/ns/pi#address> ?address
.
OPTIONAL{
?ref dc:abstract ?access
.
}
Python + SPARQLWrapper (http://sparql-wrapper.sourceforge.net/)
from SPARQLWrapper import SPARQLWrapper, JSON
sparql_wrapper = SPARQLWrapper(SPARQL URL)
query = SPARQL
sparql_wrapper.setQuery(query)
sparql_wrapper.setReturnFormat(JSON)
results = sparql_wrapper.query().convert()
SPARQL
- 14. Step2-1
q_spt = """
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX omgeo: <http://www.ontotext.com/owlim/geo#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX lodac: <http://lod.ac/ns/lodac#>
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#>
SELECT distinct ?link ?title ?lat ?long ?postalcode ?address ?access
WHERE {
?link rdf:type foaf:Organization;
rdfs:label ?title;
dc:references ?ref
.
?ref omgeo:within(%(NE_lat)s %(NE_long)s %(SW_lat)s %(SW_long)s);
geo:lat ?lat;
geo:long ?long;
dc:source <http://place.yafjp.org/rdf/>;
vcard:postal-code ?postalcode;
<http://ocdi.jp/ns/pi#address> ?address
.
OPTIONAL{
?ref dc:abstract ?access
.
}
}
""" % locals()
- 15. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX omgeo: <http://www.ontotext.com/owlim/geo#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX lodac: <http://lod.ac/ns/lodac#>
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#>
PREFIX
?link <http://purl.org/dc/terms/references> ?ref .
?link dc:references ?ref .
- 16. q_spt = """
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX omgeo: <http://www.ontotext.com/owlim/geo#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX lodac: <http://lod.ac/ns/lodac#>
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#>
SELECT distinct ?link ?title ?lat ?long ?postalcode ?address ?access
WHERE {
?link rdf:type foaf:Organization;
rdfs:label ?title;
dc:references ?ref
.
?ref omgeo:within(%(NE_lat)s %(NE_long)s %(SW_lat)s %(SW_long)s);
geo:lat ?lat;
geo:long ?long;
dc:source <http://place.yafjp.org/rdf/>;
vcard:postal-code ?postalcode;
<http://ocdi.jp/ns/pi#address> ?address
.
OPTIONAL{
?ref dc:abstract ?access
.
}
}
""" % locals()
- 17. SELECT distinct ?link ?title ?lat ?long ?postalcode ?address ?access
WHERE {
?link rdf:type foaf:Organization; ?
rdfs:label ?title;
dc:references ?ref
.
?ref omgeo:within(%(NE_lat)s %(NE_long)s %(SW_lat)s %(SW_long)s);
geo:lat ?lat;
geo:long ?long; ? ? ? ;
dc:source <http://place.yafjp.org/rdf/>;
? ? ;
vcard:postal-code ?postalcode;
<http://ocdi.jp/ns/pi#address> ?address ? ?
. .
OPTIONAL{
?ref dc:abstract ?access
.
}
}
- 18. SELECT distinct ?link ?title ?lat ?long ?postalcode ?address ?access
WHERE {
?link rdf:type foaf:Organization;
rdfs:label ?title;
dc:references ?ref SELECT
.
?link URI
?ref omgeo:within(%(NE_lat)s %(NE_long)s %(SW_lat)s %(SW_long)s);
geo:lat ?lat; ?title
geo:long ?long; ?lat
dc:source <http://place.yafjp.org/rdf/>;
vcard:postal-code ?postalcode;
?long
<http://ocdi.jp/ns/pi#address> ?address ?postalcode
. ?address
OPTIONAL{
?access
?ref dc:abstract ?access
.
}
}
- 19. SELECT distinct ?link ?title ?lat ?long ?postalcode ?address ?access
WHERE {
?link rdf:type foaf:Organization;
rdfs:label ?title; 1.
dc:references ?ref ?link
.
?ref omgeo:within(%(NE_lat)s %(NE_long)s2. ?link
%(SW_lat)s %(SW_long)s);
geo:lat ?lat;
geo:long ?long; ?title
dc:source <http://place.yafjp.org/rdf/>; ?ref
vcard:postal-code ?postalcode;
<http://ocdi.jp/ns/pi#address> ?address ※ LODAC ?link
.
1 ?ref
OPTIONAL{
?ref dc:abstract ?access ?ref
.
}
} 3. ?ref
- 20. LODAC 2
crm:P55_has_current_location dc:creator
dc:references dc:references
crm:P55_has_current_location crm:P55_has_current_location
dc:references dc:references dc:creator
dc:creator
dc:references dc:references
URI
URI
- 21. LODAC 2
crm:P55_has_current_location dc:creator
dc:references dc:references
crm:P55_has_current_location crm:P55_has_current_location
dc:references dc:references dc:creator
dc:creator
dc:references dc:references
URI
URI
- 22. SELECT distinct ?link ?title ?lat ?long ?postalcode ?address ?access
WHERE {
?link rdf:type foaf:Organization;
rdfs:label ?title;
dc:references ?ref
.
?ref omgeo:within(%(NE_lat)s %(NE_long)s %(SW_lat)s %(SW_long)s);
geo:lat ?lat;
geo:long ?long;
dc:source <http://place.yafjp.org/rdf/>;
vcard:postal-code ?postalcode; GET
<http://ocdi.jp/ns/pi#address> ?address
. ?ref
OPTIONAL{
?ref dc:abstract ?access
.
}
}
- 23. omgeo?
✦ ?ref
?ref geo:lat ?lat;
geo:long ?long.
FILTER(?lat < 35.432916 && ?lat > 35.475012 &&
?long < 139.608699 && ?long > 139.652644)
✦ omgeo 1
?ref omgeo:within(35.475012 139.652644 35.439216 139.608699).
✴ OWLIM
virtuoso
✴ ●●km
- 24. SELECT distinct ?link ?title ?lat ?long ?postalcode ?address ?access
WHERE {
?link rdf:type foaf:Organization;
rdfs:label ?title;
dc:references ?ref
.
?ref omgeo:within(%(NE_lat)s %(NE_long)s %(SW_lat)s %(SW_long)s);
geo:lat ?lat;
geo:long ?long;
dc:source <http://place.yafjp.org/rdf/>;
vcard:postal-code ?postalcode;
<http://ocdi.jp/ns/pi#address> ?address
.
OPTIONAL{
?ref dc:abstract ?access
<http://place.yafjp.org/rdf/>
.
}
}
?lat ?postalcode
?long ?address
- 25. SELECT distinct ?link ?title ?lat ?long ?postalcode ?address ?access
WHERE {
?link rdf:type foaf:Organization;
rdfs:label ?title;
dc:references ?ref
.
?ref omgeo:within(%(NE_lat)s %(NE_long)s %(SW_lat)s %(SW_long)s);
geo:lat ?lat;
geo:long ?long;
dc:source <http://place.yafjp.org/rdf/>;dc:abstract
?ref
vcard:postal-code ?postalcode; ?access
<http://ocdi.jp/ns/pi#address> ?address
. OPTIONAL
OPTIONAL{
?ref dc:abstract ?access
.
}
}
- 26. SPARQL JSON
{"spt": {"head": {"vars": ["link", "title", "lat", "long", "postalcode",
"address", "access"]}, "results": {"bindings": [{"title": {"xml:lang": "ja",
"type": "literal", "value": "u6a2au6d5cu7f8eu8853u9928"}, "long":
{"datatype": "http://www.w3.org/2001/XMLSchema#float", "type": "typed-literal",
"value": "139.63044"}, "access": {"type": "literal", "value": "u685cu6728u753a
u99c5(JR)u4e0bu8ecau3001u52d5u304f
u6b69u9053u3092u5229u7528u5f92u6b6910u5206u3002u307fu306au3068u307f
u3089u3044u99c5(u307fu306au3068u307fu3089u3044u7dda)u4e0bu8eca
u3001u300cu7f8eu8853u9928u53e3u300du3092u51fa
u3066u5f92u6b693u5206u3002"}, "postalcode": {"type": "literal", "value":
"220-0012"}, "link": {"type": "uri", "value": "http://lod.ac/id/3172"},
"address": {"xml:lang": "ja", "type": "literal", "value": "u6a2au6d5c
u5e02u897fu533au307fu306au3068u307fu3089u30443u4e01u76ee4-1"}, "lat":
{"datatype": "http://www.w3.org/2001/XMLSchema#float", "type": "typed-literal",
"value": "35.45722"}}, {"title": {"xml:lang": "ja", "type": "literal", "value":
"u307fu306au3068u307fu3089u3044u30aeu30e3u30e9u30eau30fc"}, "long":
{"datatype": "http://www.w3.org/2001/XMLSchema#float", "type": "typed-literal",
"value": "139.6341"}, "postalcode": {"type": "literal", "value": "220-0012"},
"link": {"type": "uri", "value": "http://lod.ac/id/530977"}, "address":
{"xml:lang": "ja", "type": "literal", "value": "u795eu5948u5dddu770cu6a2a
u6d5cu5e02u897fu533au307fu306au3068u307fu3089u30442u4e01u76ee3-5"},
"lat": {"datatype": "http://www.w3.org/2001/XMLSchema#float", "type": "typed-
…
- 28. Step2-2
✦ ?link
?link ical:dtstart ?dtstart ;
ical:dtend ?dtend .
FILTER (
(?dtstart > "%(dtstart)s"^^xsd:dateTime
&& ?dtstart < "%(dtend)s"^^xsd:dateTime)
||
(?dtend > "%(dtstart)s"^^xsd:dateTime
&& ?dtend < "%(dtend)s"^^xsd:dateTime)
||
(?dtstart < "%(dtstart)s"^^xsd:dateTime
&& ?dtend > "%(dtend)s"^^xsd:dateTime)
)
✦ … dateTime FILTER 0
Sesame
- 29. Step3
q_spt = """
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-
ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX omgeo: <http://www.ontotext.com/owlim/geo#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX lodac: <http://lod.ac/ns/lodac#>
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#>
SELECT distinct ?link ?title ?lat ?long ?postalcode ?
address ?access
WHERE {
?link rdf:type foaf:Organization;
rdfs:label ?title;
dc:references ?ref
.
?ref omgeo:within(%(NE_lat)s %(NE_long)s %(SW_lat)s
%(SW_long)s);
geo:lat ?lat;
geo:long ?long;
dc:source <http://place.yafjp.org/rdf/>;
vcard:postal-code ?postalcode;
<http://ocdi.jp/ns/pi#address> ?address
.
OPTIONAL{
?ref dc:abstract ?access
.
}
1. 1
2. JSON
3. JSON
✦ or
ON/OFF
✦
- 30. SPARQL LOD
✦
omgeo:within
✦ Semantic Media Wiki
→ Wiki SPARQL
✦
DBpedia GeoNames
✦
dc:created
1990 [1980] 1990 c. 1990 1980-90 55