====== Introduction. Modeling knowledge with Resource Description Framework (RDF) ====== ^ Last verification: | 20190930 | ^ Tools required for this lab: | Pens and paper | ===== Before the lab ===== Reading: * [[http://www.slate.com/articles/technology/future_tense/2015/11/why_does_google_say_jerusalem_is_the_capital_of_israel.html|Why Does Google Say Jerusalem Is the Capital of Israel?]] * [[http://www.w3.org/TR/rdf11-primer/|RDF Primer]]: general ideas about RDF; we will use only Turtle syntax so you can simply omit sections 5.2-5.4 * {{quick-tutorial-rdf-turtle.pdf|A Quick Tutorial on the Turtle RDF Serialization}} * [[#if_you_want_to_know_more|If you want to know more...]] ===== Lab instructions ===== ==== - Images annotation [5 minutes] ==== - Open [[http://www.kanzaki.com/works/2016/pub/image-annotator|Image Annotator]] - Enter URL for some image you like - Select some regions on the picture and add descriptions for them - Generate file using "Show JSON-LD" button - Analyse the file. How regions' information is represented? Copy the source into the [[#report]] 8-). ==== - FOAF [10 minutes] ==== - Create your FOAF file with: [[http://www.ldodds.com/foaf/foaf-a-matic|foaf-o-matic]] - Save your FOAF file. Put it in the report 8-). - Publish your file so that it can be referenced with URL. Put the URL into the report 8-) - Visualize your FOAF file with [[http://foaf-visualizer.gnu.org.ua/|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 - Add more friends using their FOAF files. Visualize again. ==== - Linked Open Data [15 minutes] ==== - Read about the [[http://en.wikipedia.org/wiki/Linked_Data|Linked Data]] idea (and the [[http://www.w3.org/DesignIssues/LinkedData.html|original note by T. Berners-Lee, plus the 5 star system]]) - Analyze the [[http://lod-cloud.net/|clickable LOD diagram]], choose 5 datasets and in a few words describe them in the report (what information do they contain?) 8-) ==== - 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// - Let's consider a simple knowledge graph (//taken from [[http://www.w3.org/TR/rdf11-primer/|RDF 1.1 Primer]]//): \\ {{:pl:dydaktyka:semweb:rdf-primer-graph1.jpg?500|}} - 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: [[http://www.foaf-project.org/|FOAF]] (''foaf:'') and [[http://dublincore.org/metadata-basics/|Dublin Core]] (''dcterms:''). \\ {{:pl:dydaktyka:semweb:rdf-primer-graph4.jpg?500|}} - Every arrow represents now a simple RDF Statement (RDF triple) so we can write it down using [[http://www.w3.org/TR/turtle/|Turtle notation]]: BASE PREFIX foaf: PREFIX xsd: PREFIX schema: PREFIX dcterms: PREFIX wd: a foaf:Person ; foaf:knows ; schema:birthDate "1990-07-04"^^xsd:date ; foaf:topic_interest wd:Q12418 . wd:Q12418 dcterms:title "Mona Lisa" ; dcterms:creator . dcterms:subject wd:Q12418 . - If you then visualize this code using simple RDF visualization you will get graph like that (you can click on graph to enlarge it): \\ {{:pl:dydaktyka:semweb:rdf-primer-validator-graph.png?direct&600|}} * 8-) Why is the node for "http://example.org/bob#me" __oval__ and the node for "Mona Lisa" __rectangular__? What's the difference between these two resources? ==== - 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? ;) - Go to the [[http://any23.org/|Anything to Triples]] webpage and in section "Convert document at URI": * select: **turtle** from drop-down list (default is best) * change URL from ''http://twitter.com/cygri'' to ''http://krzysztof.kutt.pl/foaf.rdf'' * validation: **validate** * report: **checked** * annotate: **unchecked** * click "Convert" button - You will get an XML with a lot of empty tags and Turtle code inside '''' - Analyze returned model. Especially look at last five statements: foaf:knows _:node1a07qklgvx22181 . _:node1a07qklgvx22181 a foaf:Person ; foaf:name "Weronika T. Adrian" ; foaf:mbox_sha1sum "fdaa9a764e8c1a218e814a043995d41a3f248ddd" ; rdfs:seeAlso . * 8-) What's the meaning of the ''_:node1a07qklgvx22181'' object (numbers may differ in your results)? - 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. ==== - Modeling knowledge with RDF graphs [25 minutes] ==== RDF is a data model based on principle of representing relational information as labeled directed graphs. - 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): - **The Bold and the Beautiful** -- you can use a [[wp>The_Bold_and_the_Beautiful#Premise]] section on wikipedia (or [[http://pl.wikipedia.org/wiki/Moda_na_sukces#Historia_rodziny_Forrester.C3.B3w|the polish one]]) - **The Game of Thrones** -- you can use a [[wp>A_Song_of_Ice_and_Fire#Plot_synopsis]] section on wikipedia - Read the selected fragment and extract as much information as you can. - **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"//. - 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. - You don't need to write long URIs, simply identify the resources with names and surnames etc. - 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 ===== - Answer the questions marked 8-) in this lab. - (Optionally) Add extra //feedback// section in the report to earn extra credit. ===== If you want to know more ===== Reading: * [[https://github.com/JoshData/rdfabout/blob/gh-pages/intro-to-rdf.md|What is RDF and what is it good for?]] * [[http://www.w3.org/TR/turtle/|Turtle syntax for RDF]] * [[http://www.w3.org/TR/rdf11-concepts/|RDF Abstract Syntax]] * [[http://www.w3.org/2000/10/swap/Primer.html|Primer: Getting into RDF & Semantic Web using N3]] * RDFS enables simple reasoning: [[https://www.w3.org/TR/rdf11-mt/#patterns-of-rdfs-entailment-informative|Patterns of RDFS entailment]] Common vocabularies: * [[http://www.w3.org/TR/skos-primer/|SKOS]] * [[http://www.dublincore.org/metadata-basics/|Dublin Core]] * [[http://xmlns.com/foaf/spec/|FOAF]] RDF serialization in XML: * [[http://www.w3schools.com/xml/xml_rdf.asp|RDF at W3Schools (part of Web Services Tutorial)]] Tools: * [[http://loki.ia.agh.edu.pl/wiki/docs:rdfeditor|RDF Editor]] developed at AGH UST (by Artur SmaroĊ„, EIS 2015-2016) * [[http://jena.apache.org/tutorials/rdf_api.html|Apache Jena]] * RDF Visualizers summary: [[pl:dydaktyka:semweb:2014:projects:rdfviz]] (in Polish) Articles: * [[https://opensource.com/life/15/11/segrada-open-source-semantic-graph-database|Historians and detectives keep track of data with open source tool]] Others: * [[http://prefix.cc/|prefix.cc - namespace lookup for RDF developers]]