Semantic Web Bootcamp

46
Semantic Web Bootcamp Dominic DiFranzo PhD Student/Research Assistant Rensselaer Polytechnic Institute Tetherless World Constellation

description

Semantic Web Bootcamp. Dominic DiFranzo PhD Student/Research Assistant Rensselaer Polytechnic Institute Tetherless World Constellation. http://tw.rpi.edu/portal/Mashathon. Interwebs?. Internet – graph of computers connected to one another - PowerPoint PPT Presentation

Transcript of Semantic Web Bootcamp

Page 1: Semantic Web  Bootcamp

Semantic Web Bootcamp

Dominic DiFranzoPhD Student/Research AssistantRensselaer Polytechnic InstituteTetherless World Constellation

Page 2: Semantic Web  Bootcamp

http://tw.rpi.edu/portal/Mashathon

Page 3: Semantic Web  Bootcamp

Interwebs? Internet – graph of computers

connected to one another Web – graph of documents hyper-

linked to one another Semantic web – graph of

concepts/ideas/data linked together by named relations.

Page 4: Semantic Web  Bootcamp
Page 5: Semantic Web  Bootcamp

128.21.52.3

122.121.53.13

138.41.32.13

122.11.32.43

125.71.26.73

Page 6: Semantic Web  Bootcamp

128.21.52.3

122.121.53.13

138.41.32.13

122.11.32.43

125.71.26.73

Page 7: Semantic Web  Bootcamp

128.21.52.3

122.121.53.13

138.41.32.13

122.11.32.43

125.71.26.73

Example.com

Cat.com/new.html dog.com/dog.html

Hat.com/hog.html

Dig.net/log.html

Page 8: Semantic Web  Bootcamp

http://difranzo.com/index http://rpi.edu/~hendler

Page 9: Semantic Web  Bootcamp

http://difranzo.com/index http://rpi.edu/~hendler

http://example.com/isAdvisedBy

Page 10: Semantic Web  Bootcamp

Example.com

Cat.com/new.html dog.com/dog.html

Hat.com/hog.html

Dig.net/log.html

Page 11: Semantic Web  Bootcamp

RDF•Triple: Subject Predicate Object•Use URI for universal naming•New York has the postal

abbreviation NY•<urn:x-states:New%20York>

<http://purl.org/dc/terms/alternative> "NY" .

Page 12: Semantic Web  Bootcamp

urn:x-states:New%20York

“NY”http://purl.org/dc/terms/alternative

Page 13: Semantic Web  Bootcamp

serialize in many ways

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dcterms="http://purl.org/dc/terms/">

<rdf:Description rdf:about="urn:x-states:New%20York"> <dcterms:alternative>NY</dcterms:alternative>

</rdf:Description></rdf:RDF>

Page 14: Semantic Web  Bootcamp

Linking

•I found a new dataset and it has the following triple

•<http://dbpedia.org/page/New_York> <http://dbpedia.org/ontology/Place/otherName> “The Empire State” .

Page 15: Semantic Web  Bootcamp

http://dbpedia.org/page/New_York

“The Empire State”

http://dbpedia.org/ontology/Place/otherName

Page 16: Semantic Web  Bootcamp

owl:sameAS

•<urn:x-states:New%20York> <http://www.w3.org/2002/07/owl#sameAs> <http://dbpedia.org/page/New_York> .

Page 17: Semantic Web  Bootcamp

urn:x-states:New%20York http://dbpedia.org/page/New_York

http://www.w3.org/2002/07/owl#sameAs

“NY” “The Empire State”

Page 18: Semantic Web  Bootcamp
Page 19: Semantic Web  Bootcamp
Page 20: Semantic Web  Bootcamp
Page 21: Semantic Web  Bootcamp
Page 22: Semantic Web  Bootcamp

Linked Datadecentralized - sources may be spread out

and referenced across the Web modular - linked without advance planning

or coordination scalable - once store in place, it’s easy to

extend advantages hold even when definitions and

structure of the data changes over time.

Page 23: Semantic Web  Bootcamp
Page 24: Semantic Web  Bootcamp
Page 25: Semantic Web  Bootcamp

Other Sem Web Tech Resource Description Framework Schema

(RDFS) Defining the vocabularies intended to be

used in RDF class, property, type, subClassOf, range,

and domain Allows for reasoning over data

• Web Ontology Language (OWL) • more expressive ontologies and more

complex reasoning of them

Page 26: Semantic Web  Bootcamp
Page 27: Semantic Web  Bootcamp

Sparql

•SPARQL is a query language for the Semantic Web.

Page 28: Semantic Web  Bootcamp

SparqlSELECT ?node ?title WHERE{  ?node <http://purl.org/dc/elements/1.1/title> ?title . } LIMIT 1

Page 29: Semantic Web  Bootcamp

?node

http://purl.org/dc/elements/1.1/title

?title

Page 30: Semantic Web  Bootcamp

Long! SELECT ?node ?name WHERE{  ?node <http://xmlns.com/foaf/0.1/givenname> ?name .  ?node <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . } LIMIT 10

Page 31: Semantic Web  Bootcamp

?node

http://purl.org/dc/elements/1.1/title

?title

foaf:Person

http://www.w3.org/1999/02/22-rdf-syntax-ns#type

Page 32: Semantic Web  Bootcamp

PrefixPREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?node ?name WHERE{  ?node foaf:givenname ?name .  ?node rdf:type foaf:Person . } LIMIT 10

Page 33: Semantic Web  Bootcamp

Shortcuts PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?node ?name WHERE{  ?node foaf:givenname ?name ; rdf:type foaf:Person . } LIMIT 10

Page 34: Semantic Web  Bootcamp

Graphs

Page 35: Semantic Web  Bootcamp

Named GraphPREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT ?graph ?node ?title WHERE{ GRAPH ?graph{  ?node dc:title ?title . } } LIMIT 3

Page 36: Semantic Web  Bootcamp

Named GraphPREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT  ?node8 ?desc8 ?node401 ?desc401 WHERE{ GRAPH <http://data-gov.tw.rpi.edu/vocab/Dataset_401>{  ?node401 dc:description ?desc401 . } GRAPH <http://data-gov.tw.rpi.edu/vocab/Dataset_8>{  ?node8 dc:description ?desc8 . } } LIMIT 3

Page 37: Semantic Web  Bootcamp

Union PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT  ?node8 ?desc8 ?node401 ?desc401 WHERE{ { GRAPH <http://data-gov.tw.rpi.edu/vocab/Dataset_401>{  ?node401 dc:description ?desc401 . } }UNION{ GRAPH <http://data-gov.tw.rpi.edu/vocab/Dataset_8>{  ?node8 dc:description ?desc8 . } } } LIMIT 3

Page 38: Semantic Web  Bootcamp

OptionalPREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT  ?node ?name ?givenname WHERE{  ?node foaf:name ?name . OPTIONAL{  ?node foaf:givenname ?givenname . } }

Page 39: Semantic Web  Bootcamp

Filter PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT  ?node ?name ?givenname WHERE{  ?node foaf:name ?name .  ?node foaf:givenname ?givenname . FILTER regex(?name, "Biden") . }

Page 40: Semantic Web  Bootcamp

SPARQLProxyThis is a web service that allows you

to query any SPARQL endpoint, and get back the results in any format you want.

A RESTful way to query any endpoint in any environment.

Page 41: Semantic Web  Bootcamp

SPARQLProxyhttp://logd.tw.rpi.edu/sparql?Paramiters:query: [required] encoded String of SPARQL queryquery-uri :[required] URI of SPARQL query (use as an

alternative to "query" parameter. These two parameters are mutul-exclusive)

Page 42: Semantic Web  Bootcamp

SPARQLProxyservice-uri: [required] URI of SPARQL Endpoint – default

is the LOGD endpoint

output: output format. ''xml'' - SPARQL/XML (default) : ''exhibit'' - JSON for MIT Exhibit : ''gvds'' - JSON for Google Visualization : ''csv'' - CSV : ''html'' - HTML table : “sparql” - SPARQL JSON

Page 43: Semantic Web  Bootcamp

Examplehttp://logd.tw.rpi.edu/sparql.php?query-

option=text&query=PREFIX+conversion%3A+%3Chttp%3A%2F%2Fpurl.org%2Ftwc%2Fvocab%2Fconversion%2F%3E%0D%0ASELECT+%3Fg+sum%28+%3Ftriples+%29+as+%3Festimated_triples%0D%0AWHERE+{%0D%0A++GRAPH+%3Fg++{%0D%0A+++%3Fg+void%3Asubset+%3Fsubdataset+.%0D%0A+++%3Fsubdataset+conversion%3Anum_triples+%3Ftriples+.%0D%0A++}%0D%0A}+%0D%0AGROUP+BY+%3Fg%0D%0A&service-uri=&output=html&callback=&tqx=&tp=

Page 44: Semantic Web  Bootcamp

Example// compose query $sparqlproxy_uri = "http://logd.tw.rpi.edu/ws/sparqlproxy.php" $params = array(); $params["query-uri"] = "http://logd.tw.rpi.edu/demo/retrieving-sparql-results/datagov-list-loaded-dataset.sparql"; $params["service-uri"] = "http://services.data.gov/sparql"; $params["output"] = "gvds"; $query= $sparqlproxy_uri."?". http_build_query($params,,'&') ; //specific for Drupal //show query result echo file_get_contents($query);

Page 45: Semantic Web  Bootcamp

Try some on your own

Page 46: Semantic Web  Bootcamp

Questions?