You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""**TASK 6.1: Reproduce the taxonomy of classes shown in slide 34 in class (all the classes under "Vocabulario", Slidedeck: 01a.RDF(s)-SPARQL). Add labels for each of them as they are in the diagram (exactly) with no language tags. Remember adding the correct datatype (xsd:String) when appropriate**
"""**TASK 6.2: Add the 3 properties shown in slide 36. Add labels for each of them (exactly as they are in the slide, with no language tags), and their corresponding domains and ranges using RDFS. Remember adding the correct datatype (xsd:String) when appropriate. If a property has no range, make it a literal (string)**"""
"""**TASK 6.4: Add to the individual person:Oscar the email address, given and family names. Use the properties already included in example 4 to describe Jane and John (https://raw.githubusercontent.com/FacultadInformatica-LinkedData/Curso2025-2026/master/Assignment4/course_materials/rdf/example4.rdf). Do not import the namespaces, add them manually**
"""**TASK 7.1a: For all classes, list each classURI. If the class belogs to another class, then list its superclass.**
31
+
**Do the exercise in RDFLib returning a list of Tuples: (class, superclass) called "result". If a class does not have a super class, then return None as the superclass**
32
+
"""
33
+
34
+
# TO DO
35
+
36
+
37
+
# Visualize the results
38
+
result= [] #list of tuples
39
+
40
+
result= [
41
+
(cls, sup)
42
+
forclsing.subjects(RDF.type, RDFS.Class)
43
+
forsupin (list(g.objects(cls, RDFS.subClassOf)) or [None])
44
+
]
45
+
forrinresult:
46
+
print(r)
47
+
48
+
## Validation: Do not remove
49
+
report.validate_07_1a(result)
50
+
51
+
"""**TASK 7.1b: Repeat the same exercise in SPARQL, returning the variables ?c (class) and ?sc (superclass)**"""
52
+
53
+
query="""SELECT ?c ?sc WHERE {
54
+
?c a rdfs:Class .
55
+
OPTIONAL { ?c rdfs:subClassOf ?sc }
56
+
} """
57
+
58
+
forring.query(query):
59
+
print(r.c, r.sc)
60
+
61
+
## Validation: Do not remove
62
+
report.validate_07_1b(query,g)
63
+
64
+
"""**TASK 7.2a: List all individuals of "Person" with RDFLib (remember the subClasses). Return the individual URIs in a list called "individuals"**
"""**Task 7.4: List the name of those entities who have a colleague with a dog, or that have a collegue who has a colleague who has a dog (in SPARQL). Return the results in a variable called name**"""
0 commit comments