Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 ARIN – KR Practical 1, Part 2 RDF Some of these slides are based on tutorial by Ivan Herman (W3C) reproduced here with kind permission. All changes and.

Similar presentations


Presentation on theme: "1 ARIN – KR Practical 1, Part 2 RDF Some of these slides are based on tutorial by Ivan Herman (W3C) reproduced here with kind permission. All changes and."— Presentation transcript:

1 1 ARIN – KR Practical 1, Part 2 RDF Some of these slides are based on tutorial by Ivan Herman (W3C) reproduced here with kind permission. All changes and errors are mine. Suresh Manandhar, Dimitar Kazakov

2 2 Lecture Overview Overview RDF RDF examples RDF tools

3 3 Need a language to describe graphs Besse, Christianne Le palais des miroirs f:original f:nom f:traducteur f:auteur f:titre http:// …isbn/2020386682 f:nom Ghosh, Amitav http://www.amitavghosh.com The Glass Palace 2000 London Harper Collins a:title a:year a:city a:p_name a:name a:homepage a:author a:publisher http:// …isbn/000651409X http:// …foaf/Person r:type http://dbpedia.org/../Amitav_Ghosh http://dbpedia.org/../The_Hungry_Tide http://dbpedia.org/../The_Calcutta_Chromosome http://dbpedia.org/../Kolkata http://dbpedia.org/../The_Glass_Palace r:type foaf:namew:reference w:author_of w:born_in w:isbn w:long w:lat

4 4 RDF stands for Resource Description Framework RDF is a language for describing labelled graphs nodes are URIs (all web applications understand these) edges can have labels which are also URIs allows namespaces + additional datatypes: Containers Strings, Decimals, Floats etc from XML Schema RDF provides this

5 5 RDF triples An RDF Triple (subject,predicate,object) is such that:  “s”, “p” are URI-s, ie, resources on the Web; “o” is a URI or a literal “s”, “p”, and “o” stand for “subject”, “property” or “predicate”, and “object”  here is the complete triple: RDF is a general model for such triples (with machine readable formats like RDF/XML, Turtle, N3, RDFa, Json, …) (,, )

6 6 Resources can use any URI http://www.mysite.com http://www.example.org/file.html#home http://www.example.org/form?a=b&c=d RDF triples form a directed, labelled graph (the best way to think about them!) RDF triples (cont.)

7 7 A simple RDF example (in Turtle) @prefix my: @prefix dc:. dc:title "Le palais des mirroirs"@fr ; my:original. @prefix my: @prefix dc:. dc:title "Le palais des mirroirs"@fr ; my:original. my:original dc:title http:// …isbn/2020386682 Le palais des miroirs http:// …isbn/000651409X

8 8 Note: Turtle @prefix my: @prefix dc:. dc:title "Le palais des mirroirs"@fr ; my:original. @prefix my: @prefix dc:. dc:title "Le palais des mirroirs"@fr ; my:original. is expanded as: Le palais des mirroirs Le palais des mirroirs

9 9 = Same RDF example (in RDF/XML) Le palais des mirroirs Le palais des mirroirs my:original dc:title http:// …isbn/2020386682 Le palais des miroirs http:// …isbn/000651409X

10 10 = Same RDF example (in RDFa) The book entitled “ Le palais des mirroirs ” is the French translation of the “ Glass Palace ”. The book entitled “ Le palais des mirroirs ” is the French translation of the “ Glass Palace ”. my:original dc:title http:// …isbn/2020386682 Le palais des miroirs http:// …isbn/000651409X RDFa is a mechanism to allow embedding RDF meta-data within a HTML page

11 11 URIs made the merge possible URIs ground RDF semantics information can be retrieved using existing tools this makes the “Semantic Web”, well… “Semantic Web” URIs play a fundamental role

12 12 RDF principles Every node is a URI or a literal Every edge is a URI i.e. ground all data without exception

13 13 Namespaces Namespaces are URIs that publish a vocabulary of terms For example, the Dublin Core is a well known namespace for common meta-data items such as author, title etc.

14 14 Some common namespaces foaf: http://xmlns.com/foaf/spec/ http://xmlns.com/foaf/spec/ dc: http://dublincore.org/documents/dces/http://dublincore.org/documents/dces/ rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# http://www.w3.org/1999/02/22-rdf-syntax-ns# rdfs: http://www.w3.org/2000/01/rdf-schema# http://www.w3.org/2000/01/rdf-schema# owl: http://www.w3.org/2002/07/owl# http://www.w3.org/2002/07/owl# geonames: http://www.geonames.org/ontology#http://www.geonames.org/ontology# dbpedia: http://dbpedia.org/resource/http://dbpedia.org/resource/ (http://mappings.dbpedia.org/server/ontology/classes/ http://dbpedia.org/Datasets/Properties/)http://dbpedia.org/Datasets/Properties/

15 15 Dublin Core Elements Title Author/creator Subject/keywords Description Publisher Other Contributor Date Resource type Format Resource Identifier Source Language Relation Coverage Rights management http://dublincore.org/documents/dces/

16 16 RDF Elements Syntax names rdf:RDF, rdf:Description, rdf:ID, rdf:about, rdf:parseType, rdf:resource, rdf:li, rdf:nodeID, rdf:datatype Class names rdf:Seq, rdf:Bag, rdf:Alt, rdf:Statement, rdf:Property, rdf:XMLLiteral, rdf:List Property names rdf:subject, rdf:predicate, rdf:object, rdf:type, rdf:value, rdf:first, rdf:rest_n http://www.w3.org/1999/02/22-rdf-syntax-ns#

17 17 For new concepts Create your own namespace

18 18 Consider the following statement: “the publisher is a «thing» that has a name and an address” Until now, nodes were identified with a URI. But… …what is the URI of «thing»? “Internal” nodes London Harper Collins a:city a:p_name a:publisher http:// …isbn/000651409X

19 19 One solution: create an extra URI HarpersCollins HarpersCollins The resource will be “visible” on the Web  care should be taken to define unique URI-s

20 20 Or Internal identifier (“blank nodes”) HarpersCollins HarpersCollins Internal = these resources are not visible outside a:publisher _:A234. _:A234 a:p_name "HarpersCollins". a:publisher _:A234. _:A234 a:p_name "HarpersCollins". London Harper Collins a:city a:p_name a:publisher http:// …isbn/000651409X

21 21 Blank nodes require attention when merging blanks nodes with identical nodeID-s in different graphs are different implementations must be careful… Many applications prefer not to use blank nodes and define new URI-s “on-the-fly” From a logic point of view, blank nodes represent an “existential” statement “there is a resource such that…” More on blank nodes

22 22 Closer look – An example Task – to build a knowledge base for an online camera shop using RDF

23 23 Closer look – An example @prefix rdf:. @prefix :. @prefix dbpedia:. :Nikon_D300 rdf:type :DSLR. :Nikon_D300 :manufactured_by dbpedia:Nikon. :Nikon_D300 :model "D300". :Nikon_D300 :weight "0.6_kg". @prefix rdf:. @prefix :. @prefix dbpedia:. :Nikon_D300 rdf:type :DSLR. :Nikon_D300 :manufactured_by dbpedia:Nikon. :Nikon_D300 :model "D300". :Nikon_D300 :weight "0.6_kg". Task – to build a knowledge base for an online camera shop using RDF

24 24 Closer look – An example @prefix rdf:. @prefix :. @prefix dbpedia:. @prefix foaf:. :Nikon_D300 rdf:type :DSLR. :Nikon_D300 :manufactured_by dbpedia:Nikon. :Nikon_D300 :model "D300". :Nikon_D300 :weight "0.6_kg". :Nikon_D300 :reviewed_by _:x1. _:x1 foaf:givenname "John". _:x1 foaf:family_name "Smith”. @prefix rdf:. @prefix :. @prefix dbpedia:. @prefix foaf:. :Nikon_D300 rdf:type :DSLR. :Nikon_D300 :manufactured_by dbpedia:Nikon. :Nikon_D300 :model "D300". :Nikon_D300 :weight "0.6_kg". :Nikon_D300 :reviewed_by _:x1. _:x1 foaf:givenname "John". _:x1 foaf:family_name "Smith”. Blank node – to add reviewer “John Smith”

25 25 Closer look – An example @prefix rdf:. @prefix :. @prefix dbpedia:. @prefix foaf:. :Nikon_D300 rdf:type :DSLR. :Nikon_D300 :manufactured_by dbpedia:Nikon. :Nikon_D300 :model "D300". :Nikon_D300 :weight "0.6_kg". :Nikon_D300 :reviewed_by _:x1. _:x1 foaf:givenname "John". _:x1 foaf:family_name "Smith". :Nikon_D300 :bought_by _:x1. @prefix rdf:. @prefix :. @prefix dbpedia:. @prefix foaf:. :Nikon_D300 rdf:type :DSLR. :Nikon_D300 :manufactured_by dbpedia:Nikon. :Nikon_D300 :model "D300". :Nikon_D300 :weight "0.6_kg". :Nikon_D300 :reviewed_by _:x1. _:x1 foaf:givenname "John". _:x1 foaf:family_name "Smith". :Nikon_D300 :bought_by _:x1. Co-reference – Buyer and reviewer are the same

26 26 Closer look – An example

27 27 Closer look – An example ### This info can visible to all customers @prefix rdf:. @prefix :. @prefix dbpedia:. @prefix foaf:. :Nikon_D300 rdf:type :DSLR. :Nikon_D300 :manufactured_by dbpedia:Nikon. :Nikon_D300 :model "D300". :Nikon_D300 :weight "0.6_kg". :Nikon_D300 :reviewed_by :Reviewer_1. :Reviewer_1 foaf:givenname "John". :Reviewer_1 foaf:family_name "Smith”. ### This info can visible to all customers @prefix rdf:. @prefix :. @prefix dbpedia:. @prefix foaf:. :Nikon_D300 rdf:type :DSLR. :Nikon_D300 :manufactured_by dbpedia:Nikon. :Nikon_D300 :model "D300". :Nikon_D300 :weight "0.6_kg". :Nikon_D300 :reviewed_by :Reviewer_1. :Reviewer_1 foaf:givenname "John". :Reviewer_1 foaf:family_name "Smith”. Use separate ids – for buyer and reviewer Public info vs Private info

28 28 Closer look – An example ### This info is stored in private internal db :Nikon_D300 :bought_by :Cust_5636. :Cust_5636 foaf:givenname ”Sally". :Cust_5636 foaf:family_name ”Douglas”. :Cust_5636 :address_line1 ”Heslington Lane”. ### This info is stored in private internal db :Nikon_D300 :bought_by :Cust_5636. :Cust_5636 foaf:givenname ”Sally". :Cust_5636 foaf:family_name ”Douglas”. :Cust_5636 :address_line1 ”Heslington Lane”.

29 29 Converting Turtle to RDF/XML cwm --n3 camera.rdf.turtle --rdf > camera.rdf.rdf Use Python script cwm (available on your machine, and also from: http://www.w3.org/2000/10/swap/doc/cwm.html)http://www.w3.org/2000/10/swap/doc/cwm.html Use Notation3 (N3) to rdf conversion Notation3 is very similar to Turtle format though not identical Use http://www-module.cs.york.ac.uk/arin/camera.rdf.turtle - right click on the link, then select Save linked file ashttp://www-module.cs.york.ac.uk/arin/camera.rdf.turtle

30 30

31 31 Using RDF/XML validator

32 32 Using RDF/XML validator

33 33 Visualising RDF graph rdfdot -ttl camera.rdf.turtle > camera.rdf.dot Use RDF to dot converter from CPAN (Perl Repository): RDF-Trine-Exporter-GraphViz Comes with command-line tool: rdfdot (you’ve got it) Use Graphviz visualiser to view the graph

34 34 Visualising RDF graph Use Graphviz visualiser to view the graph

35 35 Turtle shortcuts :Nikon_D300 rdf:type :DSLR. :Nikon_D300 :manufactured_by dbpedia:Nikon. :Nikon_D300 :model "D300". :Nikon_D300 :weight "0.6_kg". :Nikon_D300 :reviewed_by :Reviewer_1. :Nikon_D300 rdf:type :DSLR. :Nikon_D300 :manufactured_by dbpedia:Nikon. :Nikon_D300 :model "D300". :Nikon_D300 :weight "0.6_kg". :Nikon_D300 :reviewed_by :Reviewer_1. Use of semicolon; The following two are equivalent: :Nikon_D300 rdf:type :DSLR; :manufactured_by dbpedia:Nikon; :model "D300”; :weight "0.6_kg”; :reviewed_by :Reviewer_1. :Nikon_D300 rdf:type :DSLR; :manufactured_by dbpedia:Nikon; :model "D300”; :weight "0.6_kg”; :reviewed_by :Reviewer_1.

36 36 Using shared vocabularies/ontologies “Knowledge Engineering” is the task of maintaining and designing reusable knowledge bases Using shared vocabularies allows applications/databases to be more resilient to future changes In our example, we could be more careful with the using any vocabulary that is specific to only site specific, e.g.: :Nikon_D300 :manufactured_by :model :weight :reviewed_by :Nikon_D300 :manufactured_by :model :weight :reviewed_by


Download ppt "1 ARIN – KR Practical 1, Part 2 RDF Some of these slides are based on tutorial by Ivan Herman (W3C) reproduced here with kind permission. All changes and."

Similar presentations


Ads by Google