Presentation is loading. Please wait.

Presentation is loading. Please wait.

95-733 Internet Technologies 1 Master of Information System Management Internet Technologies Making Queries on RDF.

Similar presentations


Presentation on theme: "95-733 Internet Technologies 1 Master of Information System Management Internet Technologies Making Queries on RDF."— Presentation transcript:

1 95-733 Internet Technologies 1 Master of Information System Management Internet Technologies Making Queries on RDF

2 95-733 Internet Technologies Two Approaches SPARQL - Simple Protocol And RDF Query Language - Looks like SQL - Used by Dbpedia MQL - Metaweb Query Language - Based on JSON - Used by Freebase 2 Master of Information System Management Both freebase and Dbpedia make their statements available in RDF.

3 95-733 Internet Technologies Today’s Lecture A brief look at SPARQL A brief look at MQL 3 Master of Information System Management

4 95-733 Internet Technologies 4 Master of Information System Management SPARQL SPARQL Simple Protocol and RDF Query Language W3C Recommendation January 2008 Queries written using Turtle - Terse RDF Triple Language Download Jena and ARQ Query Engine For Ruby, see ActiveRDF

5 95-733 Internet Technologies 5 Master of Information System Management SPARQL Three specifications: (1) A query language (2) A query results XML format (3) A WSDL 2.0 Data Access Protocol using HTTP and SOAP SPARQL is read only and cannot modify the RDF data

6 95-733 Internet Technologies 6 Master of Information System Management Input <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:rss="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:html="http://www.w3.org/1999/xhtml"> John Barstow Visions of Aestia by John Barstow This is shortblogger.xml The file bloggers.xml has many bloggers.

7 95-733 Internet Technologies 7 Master of Information System Management Processing PREFIX foaf: SELECT ?url FROM WHERE { ?contributor foaf:name "John Barstow". ?contributor foaf:weblog ?url. } Stored in a file called ex1.rq

8 95-733 Internet Technologies 8 Master of Information System Management Output sparql --query ex1.rq ------------------------ | url | ========================= | --------------------------------------------

9 95-733 Internet Technologies 9 Master of Information System Management Processing PREFIX foaf: PREFIX rdf: SELECT ?url FROM WHERE { ?contributor rdf:type foaf:Person. ?contributor foaf:weblog ?url. } Output sparql --query ex2.rq ------------------------- | url | =============== | -------------------------

10 95-733 Internet Technologies 10 Master of Information System Management Processing PREFIX foaf: PREFIX rdf: SELECT ?x ?n FROM WHERE { ?contributor rdf:type foaf:Person. ?contributor foaf:weblog ?x. ?contributor foaf:name ?n } All three conditions must be satisfied to match the query.

11 95-733 Internet Technologies 11 Master of Information System Management Output sparql --query ex4.rq -------------------------------------------------------------------------------------- | x | n | ================================================ | | "Seth Ladd" | | | "Morten Frederiksen" | | | "Ora Lassila" | | | "Hazaël-Massieux" | | | "Leigh Dodds" | | | "Henry Story" | | | "Jeen Broekstra" | | | "Danny Weitzner" | | | "Dan Brickley" |

12 95-733 Internet Technologies 12 Master of Information System Management Processing PREFIX foaf: PREFIX rdf: SELECT DISTINCT ?n FROM WHERE { ?contributor foaf:name ?n } Output ----------------------------------------- | n | ================= | ”Mike McCarthy" | | "Pasquale Popolizio" | | "Dean Allemang" | :

13 95-733 Internet Technologies 13 Master of Information System Management Processing PREFIX foaf: PREFIX rdf: SELECT DISTINCT ?n FROM WHERE { ?contributor foaf:name ?n } ORDER BY ?n ---------------------- | n | ============= | "Alexandre Passant" | | "Alistair Miles" | | "Andrew Matthews" | | "Benjamin Nowack" :

14 95-733 Internet Technologies 14 Master of Information System Management Semi-Structured Data Definition: If two nodes of the same type are allowed to hold different sets of properties the data is called semi- structured. SPARQL uses the OPTIONAL keyword to process semi- structured data.

15 95-733 Internet Technologies 15 Master of Information System Management Processing PREFIX foaf: PREFIX rdf: SELECT DISTINCT ?n ?interest FROM WHERE { ?contributor foaf:name ?n. OPTIONAL { ?contributor foaf:interest ?interest } } ORDER BY ?n "Tetherless World Constellation group RPI" "Tim Berners-Lee" "Uldis Bojars"

16 95-733 Internet Technologies 16 Master of Information System Management Generating XML PREFIX foaf: PREFIX rdf: SELECT ?n FROM WHERE { ?contributor foaf:name ?n. }

17 95-733 Internet Technologies 17 Master of Information System Management From The Command Line sparql --query ex8.rq --results rs/xml <sparql xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xs="http://www.w3.org/2001/XMLSchema#" xmlns="http://www.w3.org/2005/sparql-results#" > John Barstow

18 95-733 Internet Technologies MQL Metaweb Query Language Make queries against the freebase data store. The input and outputs are JSON strings. 18 Master of Information System Management

19 95-733 Internet Technologies Using MQL In A URL 19 Master of Information System Management Example from the MQL documentation. Enter the following in your browser: https://api.freebase.com/api/service/mqlread?queryhttps://api.freebase.com/api/service/mqlread?query= {“query”:{“type”:”/music/artist”,”name”:”The Police”,”album”:[]}} This is a query to freebase represented in JSON.

20 95-733 Internet Technologies Output { "code": "/api/status/ok", "result": { "album": [ "Outlandos d'Amour", "Reggatta de Blanc", "Zenyatt\u00e0 Mondatta” "The Police Live!" ], "name": "The Police", "type": "/music/artist" }, "status": "200 OK", "transaction_id”:"cache;cache03.p01.sjc1:8101;2011-10-13T15” } 20 Master of Information System Management Many more albums in the real query result.

21 95-733 Internet Technologies Another look at the query. { "query": { "type":"/music/artist", "name":"The Police", "album":[] } 21 Master of Information System Management

22 95-733 Internet Technologies Use The Query Editor http://www.freebase.comqueryeditor 22 Master of Information System Management


Download ppt "95-733 Internet Technologies 1 Master of Information System Management Internet Technologies Making Queries on RDF."

Similar presentations


Ads by Google