Lab 5: Create Linked Data from Structured Data
New data may be authored as 5 star Linked Open Data from the beginning. However, data of interest often can be stored in an alternative format such as CSV. In this lab, you will learn to set up 5 star Linked Open Data from alternative structured data formats.
Submission:
The code used to set up the 5 star linked data. Zip your files, and name your file with lab5_
Introduction:
You will use the data about the hospitals in the UK from data.gov.uk. (Links to an external site.)Download the data in CSV format downloadand the data description in a PDF file download.
To set up 5 star linked data from it, you first need to extract the information you wish to publish from the CSV data file, and then to add the extracted information in RDF graph.
JS Libraries:
You are free to choose the Javascript library to handle with the CSV data, e.g. cvs-parser (Links to an external site.).
A number of Javascript libraries for handling RDF have been developed, such as those published on http://rdf.js.org/ (Links to an external site.) . You are free to choose the Javascript library to handle RDF, e.g. rdflib.js (Links to an external site.) . If you use rdflib.js, you are suggested to start with tutorial on https://github.com/solid/solid-tutorial-rdflib.js (Links to an external site.) .
Task:
Your task is to add all the information about the hospitals (from the CSV file) to a RDF triple store. When you create the RDF triple store, you should
• Reuse the terms (classes and properties) from the existing vocabularies, e.g. FOAF, DBpedia Ontology, as much as possible. You may use Linked Open Vocabularies (LOV) (Links to an external site.) to look for the terms.
• Use prefixes and namespace pairs for pretty output.
• If you do not find the terms you need, you are also able to define classes or properties yourself. For example, the code below to write a class (when using rdflib.js).
store.add(‘:bla_bla_bla’, RDF.type, RDFS.Class)
When the RDF triple store is ready, it can be written to a document, e.g. .ttl file or store in a RDF triple store. This is not required in this lab.
Lab 6: Understanding RDFa
In this lab, you will learn how to add metadata to HTML documents using RDFa, and how structured data can be created and used. The lab is adapted from two codelabs on adding structured data to web pages by Dan Scott (Links to an external site.).
Submission: Hand in an HTML document and a virtualization of the structured data in an html file using tools like RDFa play. Zip your files, and name your file with lab6_
• Firstly, read the RDFa Lite document (Links to an external site.) , which gives a quick 15-minute introduction to the basic markup concepts in RDFa. (The overview of the full power of RDFa is available on The RDFa Primer (Links to an external site.).)
• Download the lab_6.html downloadfile, and open it in a text editor.
• There are a number of RDFa parsers that can help you check the results of your work, such as RDFa Play (Links to an external site.). Copy and paste the HTML source of lab_6.html into it. The results should show that the page currently contains no structured data.
• You will use the schema.org (Links to an external site.) vocabulary for this lab. Declare it as the default vocabulary for the HTML document.
• Specify the type of things in the HTML document.
• The recommended type is https://schema.org/TechArticle (Links to an external site.).
• Note: There are two technical articles in the document
• Use the RDFa parser to validate the results of your work.
• Specify the associate properties of TechArticle
• The schema.org types are arranged in a top-down hierarchy. Starting at the top level of the type hierarchy, browse through the Thing > CreativeWork > Article > TechArticle type hierarchy. Notice how each type inherits the properties from its parent (beginning with Thing), offers its own more specific definition, and may add its own properties to enable you to describe it more completely.
• Add the properties, name, author, datePublished, description, articleBody to the type.
• Use the RDFa parser to validate the results of your work.
• Use the implicit property, content. Why and how to use the property, please read https://www.w3.org/TR/rdfa-primer/#using-the-content-attribute (Links to an external site.)
• Improve the datePublished property using the property, content, so that the information can be interpreted by a machine as a data value in either YYYYMMDD or YYYY-MM-DD format, instead of a string.
• It can be useful for technical articles to include an indication of their intended use. It can be done using the educationalUse property of the CreativeWork type. Add anywhere within the scope of the TechArticle, so the information can be added without change the the look or content of the page
• Use an RDFa parser to validate the results of your work.
• Add embeded types. So far you have described the page using a single type and its associated properties. However, when you added the @property=”author”, the expected value for the property (the range of the property) was not a simple text string; it was supposed to be either a Person (Links to an external site.) or Organization (Links to an external site.) type. You need to define a Person type to satisfy the expected value of author.
• Add the @typeof=”Person” attribute to the same HTML element which contains the author attribute, so that you define the range for the property and are starting a new Person type scope.
• Then you can further define basic properties, familyName and givenName of the Person type
• Use an RDFa parser to validate the results of your work.
• Define that the same Person is both the author and copyrightHolder.
• You can do it using @property=”author copyrightHolder”
• Use RDFa parsers to validate the results of your work.
• Use the @resource attribute to identify things.
• Why and how to use the property, please read https://www.w3.org/TR/rdfa-lite/#resource (Links to an external site.)
• Use an RDFa parser to validate the results of your work.
• Note: “when the element contains the href (or src) attribute, @property is automatically associated with the value of this attribute rather than the textual content of the element. You should keep the link to the author in the HTML document.
• In the end, the structured data from your HTML document should look like the picture below, which is visualized in RDFa Play. (Links to an external site.)
Other information:
• Linked data can be easily generated from RDFa, using the servers, such as https://www.w3.org/2012/pyRdfa/ (Links to an external site.) , and the libraries, such as pyRdfa distiller/parser library (Links to an external site.)
• It is also possible to directly query RDFa from the web. An example python code can be found in a RDFLib example
Lab 7: Ontologies
Ontologies are the backbone of the Semantic Web. They provide formally defined meanings of things in the form of rich conceptual schemas. In this lab, you will get a better understanding of ontologies, and the web ontology language OWL.
Submission: Hand in the text document which contains the answers to the questions below, and the ontology in an owl file. Zip your files, and name your submission with lab7_
• In the previous labs, you have used the ontologies, such as FOAF vocabulary (Links to an external site.), DBpeida ontology (Links to an external site.), and Schema.org vocabulary. (Links to an external site.) Now download DBpeida ontology (Links to an external site.) , unzip the file, and open the OWL file in an editor, like Notepad++ .
• In lab 4, you have worked with the class AdministrativeRegion. Find and inspect the definition for this class in the ontology. Write a full definition for this class in a natural language text.
• For the OWL language specification, check the W3C OWL Web Ontology Language Reference (Links to an external site.)
• In lab 4, you should also have worked with the datatype property populationTotal, Find and inspect its definition in the ontology. Write a full definition for this datatype property in a natural language text.
• In lab 4, you should also have worked with the object property administrativeCenter, Find and inspect its definition in the ontology. Write a full definition for this object property in a natural language text.
• Model a simple ontology
• Protégé is recommended as the tool for ontology modelling in this lab. If you use your own computer, download the latest version from https://protege.stanford.edu/ (Links to an external site.). On the computers in lab room, you can install it from software centre. There is also a web-based version (Links to an external site.), but you need to create an account in order to use it.
• How to use Protégé, please check Protégé Documentation (Links to an external site.)
• How to create new ontology, how to save an ontology, etc, check the menu items (Links to an external site.)
• How to create classes, check views/Class Hierarchy (Links to an external site.); create object properties, check views/Object Property Hierarchy (Links to an external site.)
• Build a simple ontology of Wine described below. The example is adapted from the paper Ontology Development 101: A Guide to Creating Your (Links to an external site.) First Ontology (Links to an external site.):
• Start with defining two general concepts of Wine and Food.
• Specialize the Wine class by creating some of its subclasses: White wine, Red wine, Rosé wine. We can further categorize the Red wine class, for example, into Syrah, Red Burgundy, Cabernet Sauvignon, and so on.
• Define the properties for classes. For example, a wine’s color, body, flavor and sugar content and location of a winery. Some of the properties should be datatype properties, some are object properties. For each property, you should define its domain and range. For some properties, you may need to add classes in order to finish the definition. Note: All subclasses of a class inherit the properties of that class. A property should be attached to the most general class that can have that property!
• After you created the ontology, add a few instances. For example, we can create an individual instance Chateau-Morgon-Beaujolais to represent a specific type of Beaujolais wine. Chateau-Morgon-Beaujolais is an instance of the class Beaujolais representing all Beaujolais wines. This instance has the following property values defined:
Body: Light
Color: Red
Flavor: Delicate
Tannin level: Low
Grape: Gamay (instance of the Wine grape class)
Maker: Chateau-Morgon (instance of the Winery class)
Region: Beaujolais (instance of the Wine-Region class)
•
• When you finish the ontology, save it into the standard RDF/XML format