1 / 20

SPARQL

SPARQL. Dimitar Kazakov, with references to material by Noureddin Sadawi ARIN, 2014. Ontologies so far: RDF. RDF: a conceptual approach to representing data as triples: subject – predicate – object. It’s a family of specifications, where… Classes and properties vary: rdf vs rdfs

chelsey
Download Presentation

SPARQL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SPARQL Dimitar Kazakov, with references to material by NoureddinSadawi ARIN, 2014

  2. Ontologies so far: RDF • RDF: a conceptual approach to representing data as triples: subject – predicate – object. It’s a family of specifications, where… • Classes and properties vary: rdfvsrdfs • Various data serialisationformats: • RDF/XML • Turtle • JSON-LD, etc.

  3. OWL • A family of ontology languages with clearly defined semantics • Syntax of: OWL Lite ⊂ OWL DL ⊂ OWL Full • OWL Lite meant to restrict constructs for comp. efficiency, but expressiveness (hence complexity) ≈ OWL DL, just more awkward. • OWL DL: tailored to be a complete and decidable logic, with practical reasoning algs

  4. OWL2 • Introduces 3 subsets of the language: • EL – polynomial time reasoning complexity • QL – tailored to work with databases • RL - a rule subset of OWL2

  5. Abstract syntax vs. serialisation • At the most abstract level one uses the notation of the appropriate class of logic • This can be saved in a variety of ways, e.g. see Protégé menu:

  6. Ease of reading and expressivity can vary: • OWL2 Functional Syntax: Ontology(<http://example.com/Pop.owl> Declaration( Class( :Pop ) )) • RDF/XML syntax: <rdf:RDF ...> <owl:Ontologyrdf:about=””/> <owl:Classrdf:about=”#Pop"/> </rdf:RDF> • RDF/Turtle <http://example.com/Pop.owl> rdf:typeowl:Ontology . :Pop rdf:typeowl:Class.

  7. (cont.) • Manchester Syntax: Ontology: <http://example.com/Pop.owl> Class: Pop ______________________________________ These details are hidden away when using a GUI tool, such as Protégé, to implement the ontology. It’s still important to understand the abstract syntax, which appears in the GUI, e.g. Student ⊑ Person (a description) Father ≡ Man ⊓ Parent (a definition) _______________________________________

  8. OWL abstract syntaxe.g. here is a subset:

  9. Protégé 3.x vs 4.x • Use 3.x if application cannot abstract away from working directly with the RDF triples; or to have built-in support for SPARQL to query the database. Multi-user support, database storage possible. Supports OWL1.0 (DL, OWL Full possible.) • Use 4.x to work in pure OWL (2.0), with better optimisations of parser and memory use. No SPARQL, no DB support, no multi-u.

  10. Building an ontology with Protégé: a case study Student ⊑ Person Lecturer ⊑ Person Student ⊓ Lecturer ≡ ⊥(i.e.: disjoint(Student,Lecturer)) CSModule ⊑ Module MathsModule ⊑ Module CSModule⊓ MathsModule≡ ⊥

  11. Building an ontology with Protégé: a case study Object properties: Studies Domain= Student; Range = Module Teaches Domain = Lecturer; Range = Module Data properties: Mapping individuals to values (strings for names and acronyms, integers for student ID.)

  12. Publishing the ontology • Choose the URL where the file will be placed from the start and enter it in Protégé; • Put the file at that URL (e.g. home Web dir) when ready.

  13. SPARQL Queries • A query language for ontologies • Protégé 3.x has built-in support (not in 4.x) • We’ll save our DB in RDF/XML format… • …then use the Apache Jena-Fuseki SPARQL servlet to access it.

  14. Apache Jena-Fuseki • Serving RDF data over HTTP • Supports SPARQL for querying and updating • Get from http://jena.apache.org/download/ • jena-fuseki-1.0.1-distribution.tar.gz • tar –zxf <the above> • cd jena-fuseki-1.0.1 • ./fuseki-server -update --mem /ds • open a browser and go to localhost:3030

  15. Apache Jena-Fuseki • Control panel -> /ds [Select] • File upload (to upload you local DB) • you can then use SPARQL, e.g. SELECT * WHERE {?x ?y ?z} to see the entire DB.

  16. SPARQL queries

  17. More examples • What does this do? PREFIX uni: <http://www.cs.york.ac.uk/~kazakov/ontologies/2014/3/Student-2.owl#> SELECT ?student WHERE {?student uni:Studies uni:CS101}

  18. More examples • What does this do? PREFIX uni: <http://www.cs.york.ac.uk/~kazakov/ontologies/2014/3/Student-2.owl#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?class WHERE {?class rdfs:subClassOfuni:Person}

More Related