Lab: RDFS: Difference between revisions

From info216
No edit summary
No edit summary
Line 43: Line 43:
Create an RDF (not RDFS) graph that contains all the triples in your first graph (the one with all the people and universities). Subtract all the triples in the axiom graph from the people/university graph. Write it out to see that you are left with only the asserted and entailed triples and that none of the axioms remain.
Create an RDF (not RDFS) graph that contains all the triples in your first graph (the one with all the people and universities). Subtract all the triples in the axiom graph from the people/university graph. Write it out to see that you are left with only the asserted and entailed triples and that none of the axioms remain.


<-- Download the SKOS vocabulary from https://www.w3.org/2009/08/skos-reference/skos.rdf and save it to a file called, e.g., SKOS.rdf .
<!-- Download the SKOS vocabulary from https://www.w3.org/2009/08/skos-reference/skos.rdf and save it to a file called, e.g., SKOS.rdf .
Use the schemagen tool (it is inside your Jena folders, for example under apache-jena-3.1.1/bin) to generate a Java class for the SKOS vocabulary.  
Use the schemagen tool (it is inside your Jena folders, for example under apache-jena-3.1.1/bin) to generate a Java class for the SKOS vocabulary.  
You need to do this from a console window, using a command like "<path>/schemagen -i <infile.rdf> -o <outfile.java>".
You need to do this from a console window, using a command like "<path>/schemagen -i <infile.rdf> -o <outfile.java>".

Revision as of 07:51, 28 February 2020

Lab 7: RDFS Programming with rdflib and owlurl

Topics

Basic RDFS graph programming in RDFlib. Entailments and axioms with owlrl.

Classes/Methods/Vocabularies

owlrl.RDFSClosure (RDFS_Semantics, closure, flush_stored_triples)

Vocabularies:

RDF(type)

RDFS (label, comment, subClassOf, subPropertyOf, domain, range)

Tasks

pip install owlurl

Consider the following extensions to the task from lab 2: "University of California, Berkeley and University of Valencia are both Universities. All universities are higher education instituttions (HEIs). Having a B.Sc. from a HEI and having a M.Sc. from a HEI are special cases of gradutating from that HEI. Only persons can graduate from a HEI. That a person has a degree in a subject means that the person has expertise in that subject. Only persons can have expertise, and what they have expertise in is always a subject."

Create and output the RDFS graph in RDFlib - if you can, try to build on your example from lab 2!

Check that simple inference works - make sure that your graph contains triples like these, even if you have not asserted them explicitly:

  • that UCB and UV are HEIs
  • that Cade and Emma have both graduated from some HEI
  • that Cade and Emma both have expertises
  • that Cade and Emma are both persons
  • that biology and chemistry are both subjects

Rewrite some of your existing code to use rdfs:label in a triple and add an rdfs:comment to the same resource.

If you have more time...

Create a new RDFS graph that wraps an empty graph. This graph contains only RDFS axioms. Write it out in Turtle and check that you understand the meaning and purpose of each axiom.

Create an RDF (not RDFS) graph that contains all the triples in your first graph (the one with all the people and universities). Subtract all the triples in the axiom graph from the people/university graph. Write it out to see that you are left with only the asserted and entailed triples and that none of the axioms remain.