0% found this document useful (0 votes)
28 views22 pages

Semantic Web Ontology Lec 6 Week 3

The document provides an overview of the Semantic Web, focusing on the FOAF (Friend of a Friend) vocabulary and its properties for describing people and their relationships. It explains the Turtle syntax for RDF, including the use of prefixes and shorthand notations, as well as introduces JSON and JSON-LD as formats for representing structured data. Key concepts include the structure of JSON, the role of context and types in JSON-LD, and how they facilitate data exchange and representation.

Uploaded by

w16687118
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views22 pages

Semantic Web Ontology Lec 6 Week 3

The document provides an overview of the Semantic Web, focusing on the FOAF (Friend of a Friend) vocabulary and its properties for describing people and their relationships. It explains the Turtle syntax for RDF, including the use of prefixes and shorthand notations, as well as introduces JSON and JSON-LD as formats for representing structured data. Key concepts include the structure of JSON, the role of context and types in JSON-LD, and how they facilitate data exchange and representation.

Uploaded by

w16687118
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Year: 2024-2025

Spring Semester

Introduction to the
Semantic Web
Dr. Yasmine Mahmoud
Turtle
• foaf (Friend of a Friend)
• foaf is a popular namespace in the RDF world,
used to describe people and the relationships
between them.
• The namespace for foaf is:
http://xmlns.com/foaf/0.1/.
• foaf provides a set of properties and types
ready to represent data about people, such as
name, friendships, photos, and more.
2
Turtle
Examples of foaf properties:
• foaf:Person: A type that indicates that the
resource is a person.
• foaf:name: A property that specifies the name
of the person.
• foaf:knows: A property that specifies that a
person knows another person.

3
Turtle
• Example 7: Using Multiple Prefixes

4
Turtle
• a is a shorthand for rdf:type,
o so ex:John a foaf:Person means John is of
type foaf:Person.
• foaf:name and foaf:knows are properties from
the FOAF (Friend of a Friend) vocabulary.

5
Turtle
• Example 8: Typed Literals and Language
Tags

6
Turtle
• "30"^^xsd:integer is a typed literal for age.
• "John Doe"@en and "A software
engineer"@en are language-tagged literals in
English.

7
Turtle
• Reading (as a human) RDF in Turtle format is
much easier as you can define prefixes at the
beginning of the .ttl file, shortening each triple.
• Another feature of turtle is that multiple triples
with the same subject are grouped into blocks
(so the URI for Bob Marley for example is not
repeatedly listed), for example:

8
Turtle

9
Turtle
• This represents the exact same knowledge
graph as the previous N-Triples.
• In the top section, prefixes are defined so that
the long repeated sections of the URIs can be
written in their short form.
• For example the line.
• @prefix foaf: <http://xmlns.com/foaf/0.1/> .

10
Turtle
• lets the string foaf represent
http://xmlns.com/foaf/0.1/.
• This allows the subject
<http://xmlns.com/foaf/0.1/Person> to be
shortened to foaf:Person.

11
Turtle
• One unique shortening is the predicate
<http://www.w3.org/1999/02/22-rdf-syntax-
ns#type> which is so common, it is
represented simply with the letter a.
• Hence the N-Triple.
<http://dbpedia.org/resource/Bob_Marley>
<http://www.w3.org/1999/02/22-rdf-syntax-
ns#type>
<http://xmlns.com/foaf/0.1/Person> .
12
Turtle
• It can be shortened in Turtle to:
dbr:Bob_Marley a foaf:Person
which is a lot clearer.

13
Turtle
• You can see that the data about Bob Marley
and Jamaica is separated into separate blocks.
• This grouping along with defined prefixes,
makes Turtle format a lot easier to understand
than N-Triples.
• If you notice, related information to the subject
is separated with a semi-colon and finished
with a full-stop and a newline to indicate a
new subject.
14
What is JSON?
• JSON (JavaScript Object Notation):
o It is a lightweight data format used to store and
exchange data.
o It’s easy for humans to read and write, and easy for
machines to parse and generate.
o JSON is widely used in web applications and APIs.

15
Structure of JSON:
• JSON data is written as key-value pairs.
• Keys are always strings, and values can be:
o Strings (e.g., "name": "Ahmed")
o Numbers (e.g., "age": 30)
o Booleans (e.g., "isStudent": true)
o Arrays (e.g., "hobbies": ["reading", "swimming"])
o Objects (e.g., "address": { "city": "New York",
"zip": "10001" })

16
Example of JSON:

17
What is JSON-LD?
• JSON-LD (JSON for Linked Data):
o It is a way to represent RDF (Resource Description
Framework) data in JSON format.
o It allows you to embed structured data in JSON.

18
Structure of JSON-LD:
• Context (@context): Defines the vocabulary
and mappings for the JSON data.
• Types (@type): Specifies the type of a
resource (e.g., Person, Place).
• IDs (@id): Provides a unique identifier for a
resource.
• Language Support: Allows you to specify the
language of text values (e.g., "name": {
"@value": "John", "@language": "en" }).
19
Structure of JSON-LD:

20
Structure of JSON-LD:
• @context: Defines the vocabulary:
o name maps to http://xmlns.com/foaf/0.1/name.
o age maps to http://example.org/age.
o Person maps to http://xmlns.com/foaf/0.1/Person.
• @id: The unique identifier for John
is http://example.org/John.
• @type: John is of type Person.
• name and age are properties of John.

21

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy