SWAP2008Demo

From semanticweb.org
Jump to: navigation, search

SPARQL demo using URLs from SWAP2008 session with Danny Ayers

Using a temporary SPARQL db, from danbri, Endpoint: http://danbri.org/2008/oilit/sparql.php?

(password is 'gas'; select 'POST' and show results inline for best results).

1. Attach your (edited/improved) foaf-a-matic RDF/XML to SWAP2008.

1a. got to [[1]] and upload your file. 1b. copy the URL into SWAP2008 page.

2. We'll load it into SPARQL,

Example:

LOAD <http://danbri.org/foaf.rdf> INTO <http://example.com/danbri/>

LOAD <http://semanticweb.org/images/f/f9/Danja.xml> INTO <http://semanticweb.org/images/f/f9/Danja.xml> LOAD <http://semanticweb.org/images/6/68/Danbrifoaf-swap2008.xml> INTO <http://semanticweb.org/images/6/68/Danbrifoaf-swap2008.xml>

This puts data from a Web page into a SPARQL "named graph".

Example:

PREFIX : <http://xmlns.com/foaf/0.1/>

SELECT distinct * WHERE {

GRAPH ?g 
  {
    [ a :Person; :name ?n1 ; :knows [ :name ?n2 ] ] 
  }

FILTER ( REGEX(str(?g), "semanticweb.org"))
}

Example 2:


PREFIX : <http://xmlns.com/foaf/0.1/>
SELECT distinct * WHERE {
GRAPH ?g 
  {
    [ a :Person; :mbox_sha1sum "669fe353dbef63d12ba11f69ace8acbec1ac8b17"; ?prop ?val; ] 
  }
}

Example 3:

PREFIX : <http://xmlns.com/foaf/0.1/>
CONSTRUCT { ?s ?p ?o } WHERE {
GRAPH ?g 
  {
    ?s a :Person .
    ?s :mbox_sha1sum "669fe353dbef63d12ba11f69ace8acbec1ac8b17" .
    ?s ?p ?o .
  }
}

See http://danbri.org/2008/oilit/sparql.php?query=PREFIX+%3A+%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0D%0ACONSTRUCT+{+%3Fs+%3Fp+%3Fo+}+WHERE+{%0D%0AGRAPH+%3Fg+%0D%0A++{%0D%0A++++%3Fs+a+%3APerson+.%0D%0A++++%3Fs+%3Ambox_sha1sum+%22669fe353dbef63d12ba11f69ace8acbec1ac8b17%22+.%0D%0A++++%3Fs+%3Fp+%3Fo+.%0D%0A++}%0D%0A}%0D%0A&output=rdfxml&jsonp=&key=gas

http://dig.csail.mit.edu/2005/ajar/release/tabulator/0.8/tab.html

http://beckr.org/marbles

Example 4:

Give us name and homepage of someone who knows someone who is described as being interested in Semantic_Web...

Version A: treat the DB as a flat collection of claims

PREFIX : <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?n ?h WHERE {
     ?x a :Person . 
     ?x :name ?n . 
     ?x :homepage ?h . 
     ?x :knows [ :mbox_sha1sum ?hash1 ] .
     ?y a :Person .
     ?y  :name ?n2 .
     ?y  :interest <http://en.wikipedia.org/wiki/Semantic_web> .
     ?y :mbox_sha1sum ?hash2 . 
     FILTER (str(?hash1) = str(?hash2) )
}

Version B: assume 'knows' and 'interest' information is in different graphs and we care about their sourcing:

PREFIX : <http://xmlns.com/foaf/0.1/>

SELECT DISTINCT ?n ?h ?g1 ?g2 WHERE {

GRAPH ?g1 
 {
     ?x a :Person . 
     ?x :name ?n . 
     ?x :homepage ?h . 
     ?x  :knows [ :mbox_sha1sum ?hash1 ] .
 }

GRAPH ?g2 
 {
    ?y a :Person .
    ?y  :name ?n2 .
    ?y  :interest <http://en.wikipedia.org/wiki/Semantic_web> .
    ?y :mbox_sha1sum ?hash2 . 
 }
FILTER (str(?hash1) = str(?hash2) )
}


Version C:

Same thing, tidied up a bit.

PREFIX : <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?n ?h ?g1 ?g2 WHERE {
GRAPH ?g1  {
     [ a :Person;:name ?n ; :homepage ?h ;
         :knows [ :mbox_sha1sum ?hash1 ] ]
 }
GRAPH ?g2  {
    [ a :Person ;  :name ?n2 ;
      :interest <http://en.wikipedia.org/wiki/Semantic_web> ;
      :mbox_sha1sum ?hash1 ]
 }
}

Personal tools
Namespaces

Variants
Actions
Navigation
services
Toolbox