Ontology Engineering - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Ontology Engineering

Description:

Exercises. Write queries on Dbpedia that return the following results: Select routes and their length in miles (dbpprop:lengthMi) Select routes and their lengths ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 14
Provided by: buf132
Learn more at: http://ncor.buffalo.edu
Category:

less

Transcript and Presenter's Notes

Title: Ontology Engineering


1
Ontology Engineering
  • Lab 5 September 29, 2014

2
SPARQL
  • SPARQL Protocol and RDF Query Language
  • A query language to retrieve and manipulate data
    stored in RDF format.
  • Analogous to SQLs role in the context of
    relational databases
  • SPARQL 1.0 became an official W3C Recommendation
    on 15 January 2008
  • SPARQL, 1.1 became an official W3C Recommendation
    on March 21, 2013

3
The Structure of a SPARQL (Select) Query
  • The select clause lists the information you want
    to see.
  • The where clause is a set of statements that
    pulls the information
  • SELECT ?class
  • WHERE
  • ?class lthttp//www.w3.org/1999/02/22-rdf-syntax-
    nstypegt lthttp//www.w3.org/2002/07/owlClassgt .

4
SPARQL Useful Keywords
  • PREFIX keyword associates a prefix label with an
    IRI.
  • Simplifies writing queries on data that uses
    classes and properties from multiple namespaces
  • PREFIX rdfhttp//www.w3.org/1999/02/22-rdf-syntax
    -ns
  • PREFIX owlhttp//www.w3.org/2002/07/owl
  • SELECT ?class
  • WHERE
  • ?class rdftype owlClass .
  • Instead of
  • SELECT ?class
  • WHERE
  • ?class lthttp//www.w3.org/1999/02/22-rdf-syntax-
    nstypegt lthttp//www.w3.org/2002/07/owlClassgt .

5
Keystroke Shortcuts
  • Using to repeat the subject term over a set
    of statements in a where clause
  • SELECT ?domain ?property ?range
  • WHERE
  • ?property rdftype owlObjectProperty
  • rdfsdomain ?domain
  • rdfsrange ?range .

6
SPARQL Useful Keywords
  • DISTINCT keyword removes duplicate values from
    the result set
  • LIMIT keyword restricts the result set to some
    user defined number of values
  • PREFIX rdfslthttp//www.w3.org/2000/01/rdf-schema
    gt
  • SELECT DISTINCT ?class ?superclass
  • WHERE
  • ?class rdfssubClassOf ?superclass .
  • LIMIT 25
  • Returns no more that 25 unique pairs of classes
    and their superclasses

7
SPARQL Useful Keywords
  • OPTIONAL keyword allows information to be added
    to the solution where the information is
    available, but does not reject the solution
    because some part of the query pattern does not
    match
  • PREFIX rdfslthttp//www.w3.org/2000/01/rdf-schema
    gt
  • SELECT ?class ?superclass ?label
  • WHERE
  • ?class rdfssubClassOf ?superclass .
  • OPTIONAL ?class rdfslabel ?label .
  • Returns both classes that have and do not have
    labels

8
Exploring DBPedia
  • DBPedia is a structured store of information from
    Wikipedia. (see http//en.wikipedia.org/wiki/DBped
    ia for a summary)
  • SPARQL endpoint can be found at
    http//dbpedia.org/sparql
  • Pages for individual resources can be found at
    http//dbpedia.org/page/......

9
Different Uses of the Keyword OPTIONAL
  • The following query returns routes that are
    related to both terminal points
  • SELECT ?route ?terminalpointA ?terminalpointB
  • WHERE
  • ?route rdftype dbpedia-owlRouteOfTransportation
    .
  • ?route dbppropterminusA ?terminalpointA .
  • ?route dbppropterminusB ?terminalpointB .
  • LIMIT 100

10
Different Uses of the Keyword OPTIONAL
  • This query returns routes and their terminal
    points if they have them both
  • SELECT ?route ?terminalpointA ?terminalpointB
  • WHERE
  • ?route rdftype dbpedia-owlRouteOfTransportation
    .
  • OPTIONAL ?route dbppropterminusA
    ?terminalpointA .
  • ?route dbppropterminusB
    ?terminalpointB .
  • LIMIT 100

11
Different Uses of the Keyword OPTIONAL
  • This query returns routes and their terminal
    points if they have either of them
  • SELECT ?route ?terminalpointA ?terminalpointB
  • WHERE
  • ?route rdftype dbpedia-owlRouteOfTransportation
    .
  • OPTIONAL ?route dbppropterminusA
    ?terminalpointA .
  • OPTIONAL ?route dbppropterminusB
    ?terminalpointB .
  • LIMIT 100

12
Different Uses of the Keyword OPTIONAL
  • This query returns routes and their terminal
    point A if they have one else it will return
    their terminal point B if they have one
  • SELECT ?route ?terminalpoint
  • WHERE
  • ?route rdftype dbpedia-owlRouteOfTransportation
    .
  • OPTIONAL ?route dbppropterminusA ?terminalpoint
    .
  • OPTIONAL ?route dbppropterminusB ?terminalpoint
    .
  • LIMIT 100

13
Exercises
  • Write queries on Dbpedia that return the
    following results
  • Select routes and their length in miles
    (dbpproplengthMi)
  • Select routes and their lengths
    (dbpedia-owllength)
  • Select routes and both their length in miles and
    length if they have them both. (LIMIT BY 500)
  • Select routes and their length in miles or their
    length if they have either of them. (LIMIT BY
    500)
  • Select routes and their length in miles if they
    have one or otherwise their length. (LIMIT BY
    500)
  • Select routes that have terminal points that are
    instances of classes rather than literals
    (strings, numbers, etc.)
Write a Comment
User Comments (0)
About PowerShow.com