Introduction. Modeling knowledge with Resource Description Framework (RDF)

Last verification: 20180912
Tools required for this lab: Pens and paper

Before the lab

Reading:

Lab instructions

1 Images annotation [5 minutes]

  1. Enter URL for some image you like
  2. Select some regions on the picture and add descriptions for them
  3. Generate file using „Show JSON-LD” button
  4. Analyse the file. How regions' information is represented? Copy the source into the report 8-).

2 FOAF [10 minutes]

  1. Create your FOAF file with: foaf-o-matic
  2. Save your FOAF file. Put it in the report 8-).
  3. Publish your file so that it can be referenced with URL. Put the URL into the report 8-)
  4. Visualize your FOAF file with FOAF.Vix. Simply put the URL as an uri argument to the FOAF.Vix, e.g.: http://foaf-visualizer.gnu.org.ua/?nocache=1&uri=http://krzysztof.kutt.pl/foaf.rdf
  5. Add more friends using their FOAF files. Visualize again.

3 Linked Open Data [15 minutes]

  1. Analyze the clickable LOD diagram, choose 5 datasets and in a few words describe them in the report (what information do they contain?) 8-)

4 RDF model (and Mona Lisa) [15 minutes]

  • RDF model is a directed graph built from Statements a.k.a. triples
  • Each Statement consists of: subject, predicate and object
    • Subject can be an URI or an empty node
    • Predicate can be an URI
    • Object can be an URI, an empty node or a literal
  1. Let's consider a simple knowledge graph (taken from RDF 1.1 Primer):
  2. It is very informal and vague… So we can make it more concrete using URIs for every element in the graph. Note that we are using existing vocabularies: FOAF (foaf:) and Dublin Core (dcterms:).
  3. Every arrow represents now a simple RDF Statement (RDF triple) so we can write it down using Turtle notation:
    example.ttl
    BASE   <http://example.org/>
    PREFIX foaf: <http://xmlns.com/foaf/0.1/>
    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
    PREFIX schema: <http://schema.org/>
    PREFIX dcterms: <http://purl.org/dc/terms/>
    PREFIX wd: <http://www.wikidata.org/entity/>
     
    <bob#me>
        a foaf:Person ;
        foaf:knows <alice#me> ;
        schema:birthDate "1990-07-04"^^xsd:date ;
        foaf:topic_interest wd:Q12418 .
     
    wd:Q12418
        dcterms:title "Mona Lisa" ;
        dcterms:creator <http://dbpedia.org/resource/Leonardo_da_Vinci> .
     
    <http://data.europeana.eu/item/04802/243FA8618938F4117025F17A8B813C5F9AA4D619>
        dcterms:subject wd:Q12418 .
  4. If you then visualize this code using simple RDF visualization you will get graph like that (you can click on graph to enlarge it):
    • 8-) Why is the node for „http://example.org/bob#meoval and the node for „Mona Lisa” rectangular? What's the difference between these two resources?

5 RDF model (and Friend-of-a-Friend) [5 minutes]

In this section we will convert FOAF files from previous lab to Turtle notation. Do you have your FOAF file? ;)

  1. Go to the Anything to Triples webpage and in section „Convert document at URI”:
  2. You will get an XML with a lot of empty tags and Turtle code inside <data><![CDATA[ … ]]></data>
  3. Analyze returned model. Especially look at last five statements:
    <http://hkrzysztof.kutt.pl/foaf.rdf#me> foaf:knows _:node1a07qklgvx22181 .
    
    _:node1a07qklgvx22181 a foaf:Person ;
    	foaf:name "Weronika T. Adrian" ;
    	foaf:mbox_sha1sum "fdaa9a764e8c1a218e814a043995d41a3f248ddd" ;
    	rdfs:seeAlso <http://home.agh.edu.pl/wta/foaf.rdf> .
    • 8-) What's the meaning of the _:node1a07qklgvx22181 object (numbers may differ in your results)?
  4. Convert your own FOAF file generated during previos lab into Turtle notation and compare both versions:
    • 8-) Which notation you find more clear and easier to understand? RDF/XML or Turtle?
    • 8-) Include your converted FOAF file in the report archive.

6 Modeling knowledge with RDF graphs [25 minutes]

RDF is a data model based on principle of representing relational information as labeled directed graphs.

  1. In this task you will represent a piece of knowledge with use of the RDF graphs. Firstly, select one of the topics (we will use this topic on subsequent labs):
    1. The Bold and the Beautiful – you can use a The_Bold_and_the_Beautiful#Premise section on wikipedia (or the polish one)
    2. The Game of Thrones – you can use a A_Song_of_Ice_and_Fire#Plot_synopsis section on wikipedia
  2. Read the selected fragment and extract as much information as you can.
  3. Draw a graph (yes, with a pen and paper) representing the relations you identified in the fragment. Of course, „there's more than one way to do it”.
    1. Draw regular resources (i.e. representing persons, places etc.) as oval nodes. Draw datatype values (e.g. dates, numbers representing age etc.) as rectangular nodes.
    2. You don't need to write long URIs, simply identify the resources with names and surnames etc.
  4. 8-) Put the sketch (a scan/picture) of the graph in your report.

We will use it on the next lab! :-)

Control questions

  • How one can add semantic annotation to a web page?
  • What are:
    • resources,
    • properties,
    • statemets.
  • What does RDF use to identify resources?
  • What are the required elements of RDF file?
  • What are namespaces, how are they defined and what are they used for?

Report

  1. Answer the questions marked 8-) in this lab.
  2. (Optionally) Add extra feedback section in the report to earn extra credit.

If you want to know more

pl/dydaktyka/semweb/lab-rdfmodel.txt · ostatnio zmienione: 2018/09/14 13:45 przez kkutt
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0