程序代写代做 data structure graph html Semantic Technologies and Applications COMP5860M

Semantic Technologies and Applications COMP5860M
John Stell
Room 9.15, School of Computing
j.g.stell@leeds.ac.uk
Lecture 09 – RDF – February 2020
1

from https://www.w3.org/TR/rdf11-concepts/
The Resource Description Framework (RDF) is a framework for representing information in the Web.
[there is] an abstract syntax (a data model) which serves to link all RDF-based languages and specifications.
The abstract syntax has two key data structures:
1. RDF graphs are sets of subject-predicate-object triples,
where the elements may be
1.1 IRIs,
1.2 blank nodes, or 1.3 datatyped literals.
They are used to express descriptions of resources.
2. RDF datasets are used to organize collections of RDF graphs, and comprise a default graph and zero or more named graphs.
2

IRI, URI, URL
URL: Uniform Resource Locator.
Web Resource address, including protocol e.g. HTTP, like these
http://www.leeds.ac.uk/
http://webprod3.leeds.ac.uk/catalogue/
dynprogrammes.asp?Y=201920&P=BSC-COMP-XJ
http://www.leeds.ac.uk/images/
Mosquito Jadu credit Centers for Disease Control.JPG
URI: Uniform Resource Indicator, includes URLs
and resources having no location e.g. urn:isbn:0451450523 Could be a way of referring to a real world thing (e.g. a person)
IRI: Internationalized Resource Indicator, like URI but unicode
3

From https://www.w3.org/2001/tag/doc/identify
[RFC2396] is clear that
”A resource can be anything that has identity”.
RDF provides the ability to described resources by their relationship to one another which leads to the notion of existentally qualified resources. For example, there exists a person whose internet mailbox is identified by the URI mailto:timbl@w3.org. This identifies the person of Tim Berners-Lee by reference to the URI of his internet mailbox without it being necessary to assign a URI to identify the concept of the person Tim Berners-Lee.
URIs are Not Unique
Although the resource identified by a URI should be consistent, it does not follow that different URIs must always refer to different resources. It is perfectly reasonable for a resource to be identified by several different URIs.
4

from https://www.w3.org/TR/rdf11-concepts/
Any IRI or literal denotes something in the world (the ”universe of discourse”). These things are called resources. Anything can be a resource, including physical things, documents, abstract concepts, numbers and strings
Asserting an RDF triple says that some relationship, indicated by the predicate, holds between the resources denoted by the subject and object. This statement corresponding to an RDF triple is known as an RDF statement. The predicate itself is an IRI and denotes a property, that is, a resource that can be thought of as a binary relation.
Unlike IRIs and literals, blank nodes do not identify specific resources. Statements involving blank nodes say that something with the given relationships exists, without explicitly naming it.
5

RDF consists of triples
Triples connect a resource with a resource or with a literal
6

Example


QueensHotel



name of other hotel
105


7

https://www.w3.org/RDF/Validator/rdfval
8

RDF Concrete Syntax
􏰀 XML is recommended standard
􏰀 XML not that easy for humans
􏰀 Turtle is an often seen syntax (originated in N3) 􏰀 Turtle from “Terse RDF Triple Language”
􏰀 Turtle example on next slide
9

Turtle vs XML Comparison
Turtle
@prefix ex: .
ex:person01 ex:name “fred” .
XML


fred


10

Another Format: JSON-LD
[
{
“@graph”: [ {
“@id”: “http://example.com/person01”,
“http://example.com/name”: [
{
“@value”: “fred”
} ]
} ],
“@id”: “urn:x-arq:DefaultGraphNode”
}
]
see https://json-ld.org/playground/ for more on JSON-LD
11

@prefix rdf:
.
@prefix dcterms: .
@prefix rdfs: .
dcterms:publisher
dcterms:description
“Examples of a Publisher include a person, an
organization, or a service.”@en ;
dcterms:issued
“2008-01-14″^^ ;
a rdf:Property ;
rdfs:comment “An entity responsible for making the
resource available.”@en ;
rdfs:isDefinedBy
;
rdfs:label “Publisher”@en ;
rdfs:range dcterms:Agent ;
source: http://purl.org/dc/terms
12

https://www.w3.org/RDF/Validator/rdfval
13

One thing related to more than one?
Saying ‘Manchester is between Liverpool and Leeds’ is not a binary relation, but it can be expressed as two triples by introducing a “blank node” in RDF.
14

Between Example in XML









15

or in Turtle
@prefix ex: .
ex:between _:b .
_:b ex:end .
_:b ex:end .
Alternatively, without an explicit blank node
@prefix ex: .

ex:between
[ ex:end ,
] .
16

Containers XML
RDF has containers ( including sequences and bags)




Lecture01
Lecture02
Lecture03
Lecture04




17

Containers Turtle Syntax Sequence Example
@prefix mod: .
@prefix rdf:
mod:delivery [ a rdf:Seq ;
rdf:_1 “Lecture01” ;
rdf:_2 “Lecture02” ;
rdf:_3 “Lecture03” ;
rdf:_4 “Lecture04”
].
18

rdf Properties described in rdf
@prefix rdf: .
ex:saying rdf:type rdf:Statement;
rdf:subject ex:fish;
rdf:predicate ex:likes;
rdf:object ex:water.
rdf:type rdf:type rdf:Property.
rdfs (rdf schema) allows more complex statements, we will meet next lecture. For example:
rdfs:domain rdfs:range rdfs:subClassOf
19

Example Namespaces
Dublin Core – vocabulary for describing generic metadata dc :
dcterms :
Geonames – describes geographical features
geonames :
Friend of a Friend – people and connections foaf :
FOAF-a-matic – creates your FOAF profile

20

GeoNames
GeoNames is using 303 (See Other) redirection to distinguish the Concept (thing as is) from the Document about it.
For the town Embrun in France we have these two URIs : 1. http://sws.geonames.org/3020251/
2. http://sws.geonames.org/3020251/about.rdf
The first URI stands for the town in France.
The second URI is the document with the information geonames has about Embrun.
The geonames web server is configured to redirect requests for [1] to [2].
The redirection tells Semantic Web Agents that Embrun is not residing on the geonames server but that geonames has information about it instead.
source: https://www.geonames.org/ontology/documentation.html
21