You are on page 1of 10

COLLEGEOFCOMPUTINGANDINFORMATICS

DEPARTMENTOFINFORMATIONSCIENCE
MASTERS OF SCIENCE IN INFORMATION SCIENCE
Course Name: Semantic web Analytics
Target: Individual Assignment 1

Summited By
Name YARED MULATU
ID No: PGP /715/15

Submitted To: Dr.Abdulgeny.K (PHD)

Haramaya Univesity, Ethiopia

May 30 2023

1|Page
Answers for the given questions

1.1 Express the graph of Figure 2.6(a) as a set of triples. You will list the sets of literals, IRIs and variables
(or blanks) found in this graph

1.1 When express the graph (a) below as a set of triples it looks like the following.

answer

Set of Triples from the given graph are:

Express the graph of Figure 2.6(a) as a set of triples.


?x foaf:name "Albert".
?x m:aecrit ?l.
?l rdf:type m:Roman.
?l dc:title "La peste".
You will list the sets of literals, IRIs and variables (or blanks) found in this graph. Literals: “Albert”,
“La peste”
IRIs: foaf:name, m:aecrit, m:Roman, rdf:type, dc:title
Variables: ?x, ?l }

Question

1.2 When we express the RDF graph (b) below as a set of triples it looks like the following

2|Page
answer
Express the graph of Figure 2.7(b) as a set of triples. You will give the list of literals, IRIs and

variables (or blanks) in this graph.

h?a; foaf:mbox; "paul@e.at"ih?a; worksWith; ?bi

h?a; playsTennisWith; ?cih?b; marriedWith; ?ci

h?b; foaf:mbox; "keith@g.es"ih?b; foaf:mbox; "keith@i.com"i

L = f"paul@e.at"; "keith@i.com"; "keith@g.es"g

U = fworksWith; playsTennisWith; foaf:mbox; marriedWithg

B = f?a; ?b; ?cg

Question
3.1 When we draw an RDF graph of the following 8 triples below corresponding to these statements

Given 8 triple statements:

The corresponding RDF graph of the 8 triples above is:

Answer

3|Page
Question

1.4 Consider the following statements composing the RDF graph G:


ex:book1 rdf:type mr:Book .
ex:book1 dc:title "For whom the bell tolls" .
ex:book1 dc:date 1940 .
ex:book1 dc:creator ex:eh .
ex:book1 mr:storedIn "Living room" .
ex:book2 rdf:type mr:Book .
ex:book2 dc:title "Pour qui sonne le glas" .
ex:book2 mr:translationOf ex:book1 .
ex:book2 dc:creator ex:eh .
ex:book2 dc:date 1948 .
ex:book2 dc:publisher ex:gal .
ex:movie1 rdf:type mr:Movie . 2

4|Page
ex:movie1 dc:title "For whom the bell tolls" .
ex:movie1 mr:adaptedFrom ex:book1 .
ex:movie1 mr:director ex:sw .
ex:movie1 mr:cast ex:ib .
ex:movie1 mr:cast ex:gc .
ex:movie1 mr:storedIn "Computer drive" .
ex:movie1 dc:date 1943 .
ex:eh rdf:type foaf:Person .
ex:eh foaf:name "Ernest Hemingway" .
ex:sw rdf:type foaf:Person .
ex:sw foaf:name "Sam Wood .
ex:ib rdf:type foaf:Person .
ex:ib foaf:name "Ingrid Bergman" .
ex:gc rdf:type foaf:Person .
ex:gc foaf:name "Gary Cooper" .
ex:gal rdf:type foaf:Organization .
ex:gal foaf:name "Gallimard" .
4.1. Which different classes are there in graph G? Why are they classes?

answer
mr: Book, mr:Movie, foaf:Person and foaf:Organization.
They are classes because they are in the range of rdf:type. rdfs:Class is the range of rdf:type
from the RDFS Axiomatic triples (Definition 12). Additionally, they are also identified by uppercase
fragments

4.2 Express G as a graph in graphical form.

5|Page
Question

5. For this exercise, assume that you are querying DBPedia (dbpedia.org). The ontology is
defined by http://dbpedia.org/ontology/; Write the following queries in SPARQL syntax. You
may find it helpful to test your queries using the SPARQL endpoint (http://dbpedia.org/sparql/ ),
and exploring some of the instances to see how the data is actually structured.

5.1. Give a list of countries and their French (‘FR’) labels.

5.2. Find 50 example concepts in the DBpedia dataset.


5.3. Are there people who were born in Brussels? (use an ASK query)
5.4. Find 20 people who were born in Ghent
answer
5.1. SPARQL Query to give a list of countries and their French (‘FR’) labels.

Query Syntax:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>


PREFIX dbo: <http://dbpedia.org/ontology/>

SELECT ?country ?label


WHERE {
?country a dbo:Country ;
rdfs:label ?label .
FILTER (lang(?label) = "fr")
}

5.2 SPARQL Query to find 50 example concepts about DBpedia dataset

PREFIX dbo:< http://dbpedia.org/ontology/>


SELECT DISTINCT ?concept
WHERE {
?s a ?concept
} LIMIT 50

6|Page
5.3 SPARQL Query to check, Are there peoples who were born in Brussels? Using an ASK query

Query syntax:
PREFIX dbo: <http://dbpedia.org/ontology/>
ASK WHERE {
?person dbo:birthplace< http://dbpedia.org/resource/Brussels>

5.4 SPARQL Query to Find 20 people who were born in Ghent.

Query Syntax:
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?person WHERE {
?person dbo:birthPlace <http://dbpedia.org/resource/Ghent> .
?person a dbo:Person .
} LIMIT 20

Test queries using the SPARQL endpoint (http://dbpedia.org/sparql/)

???

Question
6. For the following questions, use the Simpsons data (simpsons.ttl.)
6.1. List everyone and the number of siblings they have.
6.2. Find the oldest and youngest person.
Answer
6.1. Query to list everyone and the number of siblings they have: using the Simpsons data (simpsons.ttl.)

Query syntax:
PREFIX simp: <https://simpsons.fandom.com/wiki/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?character (COUNT(?sibling) AS ?numSiblings)


WHERE {
?character rdf:type simp:Character ;
foaf:name ?name .

7|Page
OPTIONAL {
?character simp:sibling ?sibling .
}
}
GROUP BY ?character
ORDER BY ?name

6.2. Query to find the oldest and youngest person: using the Simpsons data (simpsons.ttl.)

Query syntax:
PREFIX simp: <https://simpsons.fandom.com/wiki/>
PREFIX rdf: < http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?person ?name ?birthDate


WHERE {
?person rdf:type simp:Character ;
foaf:name ?name ;
simp:birthDate ?birthDate .
}
ORDER BY ASC(?birthDate)
LIMIT 1
UNION
SELECT ?person ?name ?birthDate
WHERE {
?person rdf:type simp:Character ;
foaf:name ?name ;
simp:birthDate ?birthDate .
}
ORDER BY DESC(?birthDate)
LIMIT 1
Question

7. Was Barack Obama born in the US? Assume that you are querying DBPedia (dbpedia.org). The
ontology is defined by http://dbpedia.org/ontology/; Write the SPARQL query and get the exact answer.
You may find it helpful to test your queries using the SPARQL endpoint (http://dbpedia.org/sparql/), and
exploring some of the instances to see how the data is actually structured. Use the following prefixes:
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: http://dbpedia.org/resource/

Answer
7. The SPARQL query can be used to check whether Barack Obama was born in the US using the
DBpedia ontology:

8|Page
Query Syntax:

prefix dbo: <http://dbpedia.org/ontology/>


prefix dbr: <http://dbpedia.org/resource/>
select ?birthPlace
where {
dbr:Barack_Obama dbo:birthPlace ?birthPlace.
?birthPlace dbo:country dbr:United_States
}

This query first defines the prefixes for the DBpedia ontology and for the Barack Obama resource. It then
selects the birthPlace of Barack Obama using the `dbo:birthPlace` property. Finally, it checks whether the
`dbo:country` of the birthPlace is the United States.

This means that Barack Obama was born in Hawaii, which is located in the US state. Therefore, the
answer to the question is yes, Barack Obama was born in the US.

Question

8. How many instances of dbo:film in Dbpedia? Assume that you are querying DBPedia (dbpedia.org).
The ontology is defined by http://dbpedia.org/ontology/; Write the SPARQL query and get the exact
answer. You may find it helpful to test your queries using the SPARQL endpoint
(http://dbpedia.org/sparql/), and exploring some of the instances to see how the data is actually
structured. Write the SPARQL query and get the exact answer. Use the following prefix:
PREFIX dbo: <http://dbpedia.org/ontology/>
Answer
8. The SPARQL query to find the number of instances of dbo:film in DBpedia is:

Query Syntax:
PREFIX dbo:< http://dbpedia.org/ontology/>
SELECT (COUNT(?film) AS ?count)
WHERE {
?film a dbo:Film .
}

This query will count all the instances where the subject is of type ‘dbo:Film’
Running this query on the DBpedia SPARQL endpoint (http://dbpedia.org/sparql/)

Therefore, there are 176722 instances of dbo:film in DBpedia as of now

9|Page
10 | P a g e

You might also like