Professional Documents
Culture Documents
Semantic Web Analytics Assignment
Semantic Web Analytics Assignment
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
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
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
Question
3.1 When we draw an RDF graph of the following 8 triples below corresponding to these statements
Answer
3|Page
Question
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
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.
Query Syntax:
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>
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
???
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/>
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/>
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:
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/)
9|Page
10 | P a g e