Successfully reported this slideshow.

SPARQLの基礎

10

Share

1 of 48
1 of 48

More Related Content

SPARQLの基礎

  1. 1. SPARQL
  2. 2. http://oreilly.com/catalog/0636920020547/
  3. 3. http://www.w3.org/DesignIssues/LinkedData.html
  4. 4. http://wiki.dbpedia.org/OnlineAccess
  5. 5. http://dbpedia.org/sparql
  6. 6. http://id.ndl.go.jp/auth/ndla
  7. 7. http://iss.ndl.go.jp/ndla/sparql/
  8. 8. A C B D E F H G I K J L M
  9. 9. A C B D E F H G I K J L M
  10. 10. A C B D E F H G I K J L M
  11. 11. A C B D E F H G I K J L M :A ?link1 ?node1 ?node1 ?link2 ?node2
  12. 12. A like like C B like dislike D dislike dislike E F dislike like H like dislike G like I dislike K dislike like J L dislike M
  13. 13. A like like C B like dislike D dislike dislike E F dislike like H like dislike G like I dislike K dislike like J L dislike M
  14. 14. A like like C B like dislike D dislike dislike E F dislike like H like dislike G like I dislike K dislike like J L dislike M :A :like ?node1 ?node1 :like ?node2
  15. 15. rdfs:label dbpedia-owl:capital dbpedia:Japan dbpedia- owl:City rdf:type dbpedia-owl:coutnry dbpedia- dbpedia:Tokyo dbpprop:birthPlace rdf:type owl:ComicCreator dbpprop:birthPlace rdf:type dbpedia- rdfs:label dbpedia:Kaoru_Mori owl:sameAs owl:Artist owl:sameAs dbpprop:birthdate rdf:type 1978-09-18 rdfs:label foaf:homepage foaf:Person rdfs:label freebase: Мори, Каору http:// morikaoru.blog62.fc2.com
  16. 16. dbpedia-owl:Capital dbpedia:Japan dbpedia:Tokyo
  17. 17. PREFIX dbpedia: <http://dbpedia.org/resource/> PREFIX dbpedia-owl: <http://dbpedia.org/ontology/> SELECT ?country WHERE { dbpedia:Tokyo dbpedia-owl:country ?country . } rdfs:label dbpedia-owl:capital dbpedia:Japan dbpedia- owl:City rdf:type dbpedia-owl:coutnry dbpedia- dbpedia:Tokyo dbpprop:birthPlace rdf:type owl:ComicCreator dbpprop:birthPlace rdf:type dbpedia- rdfs:label dbpedia:Kaoru_Mori owl:sameAs owl:Artist owl:sameAs dbpprop:birthdate rdf:type 1978-09-18 rdfs:label foaf:homepage foaf:Person rdfs:label freebase: Мори, Каору http:// morikaoru.blog62.fc2.com
  18. 18. PREFIX dbpedia: <http://dbpedia.org/resource/> PREFIX dbpedia-owl: <http://dbpedia.org/ontology/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?birthPlace ?label WHERE { dbpedia:Kaoru_Mori dbpedia-owl:birthPlace ?birthPlace . ?birthPlace rdfs:label ?label . } rdfs:label dbpedia-owl:capital dbpedia:Japan dbpedia- owl:City rdf:type dbpedia-owl:coutnry dbpedia- dbpedia-owl:birthPlace rdf:type owl:ComicCreator dbpedia:Tokyo dbpedia-owl:birthPlace rdf:type dbpedia- rdfs:label dbpedia:Kaoru_Mori owl:sameAs owl:Artist owl:sameAs dbpprop:birthdate rdf:type 1978-09-18 rdfs:label foaf:homepage foaf:Person rdfs:label freebase: Мори, Каору http:// morikaoru.blog62.fc2.com
  19. 19. PREFIX dbpedia: <http://dbpedia.org/resource/> PREFIX dbpedia-owl: <http://dbpedia.org/ontology/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?birthPlace ?label WHERE { dbpedia:Kaoru_Mori dbpedia-owl:birthPlace ?birthPlace . ?birthPlace rdf:type dbpedia-owl:City ; rdfs:label ?label . } rdfs:label dbpedia-owl:capital dbpedia:Japan dbpedia- owl:City rdf:type dbpedia-owl:coutnry dbpedia- dbpedia-owl:birthPlace rdf:type owl:ComicCreator dbpedia:Tokyo dbpedia-owl:birthPlace rdf:type dbpedia- rdfs:label dbpedia:Kaoru_Mori owl:sameAs owl:Artist owl:sameAs dbpprop:birthdate rdf:type 1978-09-18 rdfs:label foaf:homepage foaf:Person rdfs:label freebase: Мори, Каору http:// morikaoru.blog62.fc2.com
  20. 20. PREFIX dbpedia: <http://dbpedia.org/resource/> PREFIX dbpedia-owl: <http://dbpedia.org/ontology/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?birthPlace ?label WHERE { dbpedia:Kaoru_Mori dbpedia-owl:birthPlace ?birthPlace . ?birthPlace a dbpedia-owl:City ; rdfs:label ?label . FILTER (lang(?label) = “ja”) } rdfs:label dbpedia-owl:capital dbpedia:Japan dbpedia- owl:City rdf:type dbpedia-owl:coutnry dbpedia- dbpedia-owl:birthPlace rdf:type owl:ComicCreator dbpedia:Tokyo dbpedia-owl:birthPlace rdf:type dbpedia- rdfs:label dbpedia:Kaoru_Mori owl:sameAs owl:Artist owl:sameAs dbpprop:birthdate rdf:type 1978-09-18 rdfs:label foaf:homepage foaf:Person rdfs:label freebase: Мори, Каору http:// morikaoru.blog62.fc2.com
  21. 21. SELECT * WHERE { ?s ?p ?o . } LIMIT 100 OFFSET 100
  22. 22. : yes / no PREFIX dbpedia: <http://dbpedia.org/resource/> PREFIX dbpedia-owl: <http://dbpedia.org/ontology/> ASK WHERE { dbpedia:Kaoru_Mori dbpedia-owl:birthPlace ?birthPlace . }
  23. 23. PREFIX foaf: <http://xmlns.com/foaf/0.1/> CONSTRUCT { ?s foaf:name ?name . } WHERE { ?s foaf:name ?name . }
  24. 24. ( ) DESCRIBE <http://dbpedia.org/resource/Tokyo>
  25. 25. dbpedia-owl:Artist freebase: a music.producer a freebase: owl:sameAs dbpedia: dbpedia: en.mike_oldfield Mike_Oldfield Virgin_Records freebase: dbpedia-owl: music.producer. recordLabel releases_produced dbpedia-owl: dbpedia-owl: freebase: owl:sameAs artist producer freebase: music.release. m.0328jl5 producer a freebase: dbpedia: dbpedia-owl:Album type.object.name owl:sameAs Tubular_Bells Tubular Bells owl:sameAs bbc_artists: mo:musicbrainz musicbrainz: a a1684a49-feaa-4150-b758- a1684a49-feaa-4150-b758- d9412fc59f12#artist d9412fc59f12.html mo:SoloArtist mo:imdb foaf:name imdb:nm0646131 Mike Oldfield (default-graph)
  26. 26. http://www.freebase.com http://dbpedia.org dbpedia-owl:Artist freebase: a music.producer a freebase: owl:sameAs dbpedia: dbpedia: en.mike_oldfield Mike_Oldfield Virgin_Records freebase: dbpedia-owl: music.producer. recordLabel releases_produced dbpedia-owl: dbpedia-owl: freebase: owl:sameAs artist producer freebase: music.release. m.0328jl5 producer a freebase: dbpedia: dbpedia-owl:Album type.object.name owl:sameAs Tubular_Bells Tubular Bells owl:sameAs bbc_artists: mo:musicbrainz musicbrainz: a a1684a49-feaa-4150-b758- a1684a49-feaa-4150-b758- d9412fc59f12#artist d9412fc59f12.html mo:SoloArtist mo:imdb foaf:name imdb:nm0646131 Mike Oldfield http://www.bbc.co.uk (default-graph)
  27. 27. http://www.freebase.com http://dbpedia.org dbpedia-owl:Artist freebase: a music.producer a freebase: owl:sameAs dbpedia: dbpedia: en.mike_oldfield Mike_Oldfield Virgin_Records freebase: dbpedia-owl: music.producer. recordLabel releases_produced dbpedia-owl: dbpedia-owl: freebase: owl:sameAs artist producer freebase: music.release. m.0328jl5 producer a freebase: dbpedia: dbpedia-owl:Album type.object.name owl:sameAs Tubular_Bells Tubular Bells owl:sameAs bbc_artists: mo:musicbrainz musicbrainz: a a1684a49-feaa-4150-b758- a1684a49-feaa-4150-b758- d9412fc59f12#artist d9412fc59f12.html mo:SoloArtist mo:imdb foaf:name imdb:nm0646131 Mike Oldfield http://www.bbc.co.uk (default-graph)
  28. 28. SELECT * WHERE { GRAPH <http://dbpedia.org> { ?s ?p ?o . } }
  29. 29. SELECT * WHERE { GRAPH ?g { ?s ?p ?o . } }
  30. 30. { ex:A ex:like ?tmpNode . ?tmpNode ex:like ?node . } => { ex:A ex:like/ex:like ?node } => { ex:A ex:like{2} ?node } ... => { ex:A ex:like+ ?node } { ex:A (ex:like|ex:love) ?node }
  31. 31. COUNT, SUM, MIN, MAX, AVG, GROUP_CONCAT, SAMPLE PREFIX dbpedia: <http://dbpedia.org/resource/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT (COUNT(?label) AS ?count) WHERE { dbpedia:Tokyo rdfs:label ?label . }

×