SPARQL-DL - Theory & Practice
Upcoming SlideShare
Loading in...5
×
 

SPARQL-DL - Theory & Practice

on

  • 1,017 views

Seminário apresentado na disciplina Raciocínio Automático e Representação do Conhecimento Simbólico (RAARCS) do CIn-UFPE em 11/09/2013.

Seminário apresentado na disciplina Raciocínio Automático e Representação do Conhecimento Simbólico (RAARCS) do CIn-UFPE em 11/09/2013.

Statistics

Views

Total Views
1,017
Views on SlideShare
1,010
Embed Views
7

Actions

Likes
2
Downloads
35
Comments
0

2 Embeds 7

https://twitter.com 6
http://news.google.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

SPARQL-DL - Theory & Practice Presentation Transcript

  • 1. SPARQL-DL Theory & Practice Adriel Café aac3@cin.ufpe.br
  • 2. Summary 1. OWL Basics 2. SPARQL 3. SPARQL-DL 4. Comparison: SPARQL x SPARQL-DL 5. Reasoner's Support for DL 6. Practice SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 3. Important This document was based on W3C specifications • http://w3.org/2001/sw/wiki/SPARQL-DL • http://w3.org/TR/sparql11-query • http://w3.org/TR/sparql11-overview • http://w3.org/TR/rdf-sparql-query • http://w3.org/TR/owl-guide • http://w3.org/TR/owl-features • http://w3.org/TR/owl-ref • http://w3.org/TR/owl2-overview • http://w3.org/TR/owl2-profiles SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 4. OWL Basics Ontology Web Language • Is an ontology language for the Semantic Web with formally defined meaning • Is a W3C standard since 2004 • Written in XML • Derived from the DAML+OIL • Developed as a vocabulary extension of RDF • Provide classes, properties, individuals, data values and are stored as Semantic Web documents • OWL Tools • OWL Syntax Converter (http://owl.cs.manchester.ac.uk/converter) • OWL Validator (http://owl.cs.manchester.ac.uk/validator) SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 5. OWL 1 • Compatible with RDF • Profiles • OWL Full (Not DL) • OWL DL (DL SHOIN(D)) • OWL Lite (DL SHIF(D)) OWL Versions OWL 2 • Compatible with OWL 1 and RDF • Profiles • OWL 2 EL (DL EL++) • OWL 2 QL (DL-Lite) • OWL 2 RL (DLP) • OWL 2 DL (DL SROIQ(D)) Is used informally to refer to ontologies interpreted using the Direct Semantics http://w3.org/TR/owl2-direct-semantics SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 6. OWL 2 Structure http://w3.org/TR/owl2-overview/OWL2-structure2-800.png SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 7. SPARQL SPARQL Protocol and RDF Query Language • Is a SQL-Like language for querying RDF data • Is a protocol • Is a W3C standard since 2008 • Queries consist of triple patterns, conjunctions, disjunctions, and optional patterns "SPARQL will make a huge difference“ (Berners-Lee, 2006) SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 8. SPARQL in Semantic Web Stack http://upload.wikimedia.org/wikipedia/en/3/37/Semantic-web-stack.png SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 9. SPARQL Query Types • SELECT Returns all, or a subset of, the variables bound in a query pattern match. • ASK Returns a boolean indicating whether a query pattern matches or not. • CONSTRUCT Returns an RDF graph constructed by substituting variables in a set of triple templates. • DESCRIBE Returns an RDF graph that describes the resources found. SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 10. PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT DISTINCT ?name FROM <http://xmlns.com/foaf/spec/index.rdf> WHERE { ?x foaf:name ?name } ORDER BY ?name LIMIT 5 OFFSET 10 Anatomy of a SPARQL Query Triple patterns to be localized Subject, Predicate and Object Prefix label associated with an IRI Returns all possible bindings of the provided variables DISTINCT keyword removes all redundant bindings Data sources that should be consulted Solution sequences and modifiers SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 11. RDF Definitions • RDF Triple Contains three components: subject, predicate and object <http://com.ex/people#adrielcafe> <http://com.ex/contact#name> “Adriel Café" • RDF Graph Is a set of RDF triples • Triple Pattern Is like an RDF triple, but with the option of a variable in place of RDF terms (i.e., IRIs, literals or blank nodes) in the subject, predicate or object positions ?people <http://com.ex/contact#name> ?name • Basic Graph Pattern (BGP) Is a conjunction of a finite set of triple patterns SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 12. SPARQL Subgraph Matching • The SPARQL query processor will search for sets of triples that match these triple patterns, binding the variables in the query to the corresponding parts of each triple. • Subgraph matching (a.k.a. simple entailment) considers only the graph structure of RDF for computing query results • Entailment Regimes RDFS Entailment Regime, D-Entailment Regime, OWL 2 RDF-Based Semantics, OWL 2 Direct Semantics “The main mechanism for computing query results in SPARQL is subgraph matching: RDF triples in both the queried RDF data and the query pattern are interpreted as nodes and edges of directed graphs, and the resulting query graph is matched to the data graph using variables as wild cards.” (Glimm; Krötzsch, 2010) SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 13. SPARQL-DL SPARQL Protocol and RDF Query Language – Description Logics • Is a distinct subset of SPARQL • Uses SPARQL syntax • Is tailored to ontology specific questions • Is not yet a W3C standard • Quite expressive language which allows to mix TBox, RBox, and ABox queries • Fully aligned with the OWL 2 standard • Settled on top of the OWL API SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br> http://www.derivo.de/uploads/pics/SPARQL-DL_01.png
  • 14. SPARQL-DL Abstract Syntax • A SPARQL-DL query Q is a finite set of SPARQL-DL query atoms and the query is interpreted as the conjunction of the elements in the set. SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br> Query Type of the query An example query Q1 Standard TBox query SubClassOf(?c, ex:Student) Q2 Standard ABox query Type(?x, and(ex:Student, ex:Employee)), PropertyValue(?x, ex:name, ?y) Q3 ABox query with non- distinguished variables PropertyValue(?x, ex:hasPublication, _:y), PropertyValue(:y, ex:publishedAt, _:z), Type(_:z, not(ex:Workshop)) Q4 Mixed ABox/TBox query Type(?x, ex:Student), Type(?x, ?c), SubClassOf(?c, ex:Employee), Q5 Mixed ABox/RBox query ObjectProperty(?p), PropertyValue(ex:John, ?p, ?v) (Parsia & Sirin, 2007)
  • 15. SPARQL-DL Supported Query Patterns Class(a) Property(a) Individual(a) Type(a, b) PropertyValue(a, b, c) EquivalentClass(a, b) SubClassOf(a, b) EquivalentProperty(a, b) SubPropertyOf(a, b) InverseOf(a, b) ObjectProperty(a) DataProperty(a) Functional(a) InverseFunctional(a) Transitive(a) Symmetric(a) Reflexive(a) Irreflexive(a) SameAs(a, b) DisjointWith(a, b) DifferentFrom(a, b) ComplementOf(a, b) Annotation(a, b, c) StrictSubClassOf(a, b) DirectSubClassOf(a, b) DirectType(a, b) StrictSubPropertyOf(a, b) DirectSubPropertyOf(a, b) SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 16. SPARQL-DL Syntax • Query Types: ASK and SELECT • Supports union-like statements called "OR WHERE“ • Primitives • Variable: ?[a-zA-Z]+ (for example ?a, ?myVar) • Full IRI: <http://example.com> • Prefixed IRI: [the prefix]:[the suffix] • Literal: "this is a literal" (escape the character " inside a literal with ") SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 17. SPARQL-DL Query Examples SELECT ?c WHERE { Class(?c) } SELECT ?x WHERE { Transitive(?p), PropertyValue(<http://example.com#myClass>, ?p, ?x) } PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine# SELECT ?i WHERE { Type(?i, wine:PinotBlanc) } OR WHERE { Type(?i, wine:DryRedWine) } SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 18. Query Comparison: SPARQL x SPARQL-DL • SPARQL PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine# SELECT ?wine ?region WHERE { ?wine wine:locatedIn ?region } • SPARQL-DL PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine# SELECT ?wine ?region WHERE { PropertyValue(?wine, wine:locatedIn, ?region) } SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 19. Query Comparison: SPARQL x SPARQL-DL • SPARQL PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine# SELECT ?wine ?flavor WHERE { ?wine wine:locatedIn wine:NewZealandRegion . ?wine wine:hasFlavor ?flavor } • SPARQL-DL PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine# SELECT ?wine ?flavor WHERE { PropertyValue(?wine, wine:locatedIn, wine:NewZealandRegion), PropertyValue(?wine, wine:hasFlavor, ?flavor) } SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 20. Query Comparison: SPARQL x SPARQL-DL • SPARQL PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine# SELECT ?wine WHERE { { ?wine wine:locatedIn wine:NapaRegion } UNION { ?wine wine:locatedIn wine:NewZealandRegion } } • SPARQL-DL PREFIX wine: http://w3.org/TR/2003/PR-owl-guide-20031209/wine# SELECT ?wine WHERE { PropertyValue(?wine, wine:locatedIn, wine:NapaRegion) } OR WHERE { PropertyValue(?wine, wine:locatedIn, wine:NewZealandRegion ) } SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 21. Reasoner's Support for DL Pellet RacerPro FaCT++ HermiT OWL-DL Support Yes Yes Yes Yes OWL 2 Support Yes Yes Partially Yes Supported expressivity SROIQ(D) SRIQ(D-) SROIQ(D) SHOIQ+ Reasoning algorithm Tableau Tableau Tableau Hypertableau Rule Support Yes (SWRL - DL Safe Rules) Yes (SWRL - not fully supported) & own rule format No Yes (SWRL - DL Safe Rules) Licensing Free / open-source & Non-Free/ closed- source Non-Free/ closed- source Free / open-source Free / open-source Adapted from http://en.wikipedia.org/wiki/Semantic_reasoner SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 22. Practice • Eclipse IDE (Java Project) http://eclipse.org • OWL API http://derivo.de/en/resources/owl-api.html • SPARQL-DL API http://derivo.de/en/resources/sparql-dl-api.html • HermiT OWL Reasoner http://hermit-reasoner.com • Wine Ontology http://krono.act.uji.es/Links/ontologies/wine.owl SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 23. Practice Queries • Prefix PREFIX wine: <http://krono.act.uji.es/Links/ontologies/wine.owl#> • Query 1 SELECT ?class WHERE { Class(?class) } • Query 2 SELECT ?subClass WHERE { SubClassOf(?subClass, wine:Wine) } • Query 3 SELECT ?wine WHERE { PropertyValue(?wine, wine:locatedIn, wine:GermanyRegion) } SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 24. Practice Queries • Query 4 SELECT ?wine ?region WHERE { PropertyValue(?wine, wine:locatedIn, ?region) } • Query 5 SELECT ?wine ?region WHERE { Type(?wine, wine:Wine), PropertyValue(?wine, wine:locatedIn, ?region) } • Query 6 SELECT ?wine ?flavor WHERE { PropertyValue(?wine, wine:locatedIn, wine:NewZealandRegion), PropertyValue(?wine, wine:hasFlavor, ?flavor) } SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 25. Practice Queries • Query 7 (DISTINCT Keyword) SELECT DISTINCT ?producer ?wine WHERE { PropertyValue(?producer, wine:producesWine, ?wine) } • Query 8 (OR WHERE Statement) SELECT ?wine WHERE { Type(?wine, wine:PinotBlanc) } OR WHERE { Type(?wine, wine:DryRedWine) } SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>
  • 26. Practice OWL API + SPARQL-DL API + HermiT Reasoner SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br> // Ontology IRI ontIRI = IRI.create("http://krono.act.uji.es/Links/ontologies/wine.owl"); OWLOntologyManager ontManager = OWLManager.createOWLOntologyManager(); OWLOntology ont = ontManager.loadOntologyFromOntologyDocument(ontIRI); // Reasoners OWLReasoner rStructural = new StructuralReasonerFactory().createReasoner(ont); OWLReasoner rHermit = new Reasoner.ReasonerFactory().createReasoner(ont); // Query QueryEngine queryEngine = QueryEngine.create(ontManager, rHermit); Query query = Query.create(query1); String result = queryEngine.execute(query).toString(); System.out.println(result);
  • 27. References • HORROCKS, I.; PEREZ-URBINA, H.; MOTIK, BORIS. Efficient Query Answering for OWL 2. 2009. • HORROCKS, I.; PATEL-SCHNEIDER, P. F.; MCGUINNESS, D. L.; WELTY, C. A. OWL: a Description Logic Based Ontology Language for the Semantic Web. 2007. • HORROCKS, I.; KOLLIA, I.; GLIMM, B. SPARQL Query Answering over OWL Ontologies. 2011. • KREMEN1, P.; SIRIN, E. SPARQL-DL Implementation Experience. 2008. • PARSIA, B.; SIRIN, E. SPARQL-DL: SPARQL Query for OWL-DL. 2007. • GLIMM, B.; KRÖTZSCH, M. SPARQL Beyond Subgraph Matching. 2010. • GRAU, B. C.; HORROCKS, I.; MOTIK, B.; PARSIA, B.; PATEL-SCHNEIDER, P.; SATTLER, U. OWL 2: The Next Step for OWL. 2008. • DOMINGUE, J.; FENSEL, D.; HENDLER, J. A. Handbook of Semantic Web Technologies. 2011. • ALLEMANG, D.; HENDLER J. A. Semantic Web for the Working Ontologist. 2011. • ANTONIOU, G.; VAN HARMELEN, F. Semantic Web Primer. 2008. • HEBELER, J.; FISHER, M.; BLACE, R.; PEREZ-LOPEZ, A.; DEAN, M. Semantic Web Programming. 2009. SPARQL-DL: Theory & Practice | Adriel Café <aac3@cin.ufpe.br>