In this section of the project, eleven different queries will be performed on our knowledge graph. Each question is expressed in the SPARQL language according to the RDF model and the STOP ontology. Here, you can find the jupyternotebook of the SPARQL queries
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX stop: <http://www.semanticweb.org/martinapensalfini/ontologies/2022/9/stop#>
SELECT ?topic_name
WHERE {
?song rdf:type stop:Song;
stop:is_about ?topic.
?topic stop:have_name ?topic_name.
}
Result: Death, Eternal Sleep, Nature, Dancing, Dream, Music, Nature, Suffering, Devastation, Love, Nature, Salvation, Suffering, Damnation, Hate, Justice, Knowledge, Religion, Salvation, Sickness, Suffering, Damnation, Knowledge, Salvation, Sickness, Suffering, Darkness vs light, Dream, Sight, Sky, Suffering, Damnation, Dream, Religion, Salvation, Death, Dream, Memory
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX stop: <http://www.semanticweb.org/martinapensalfini/ontologies/2022/9/stop#>
SELECT ?topic_name
WHERE {
?poem rdf:type stop:Poem;
stop:is_about ?topic.
?topic stop:have_name ?topic_name.
}
Result: Darknessvslight, Night, Sight, Sky, Church, Justice, Knowledge, Religion, Suffering, Dancing, Music, Nature, Sky, Drinking, Nature, Secret, Suffering, Darknessvslight, Dream, Memory, Music, Hate, Justice, Religion, Death, EternalSleep, Nature, Family, Marriage, Damnation, Hate, Religion, Salvation
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX stop: <http://www.semanticweb.org/martinapensalfini/ontologies/2022/9/stop#>
SELECT ?topic_name (COUNT(?unit) as ?number_of_units)
WHERE {
?topic stop:appears_in ?unit.
?topic stop:have_name ?topic_name.
}
GROUP BY ?topic
ORDER BY desc(?number_of_units)
LIMIT 1
Result: Suffering
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX stop: <http://www.semanticweb.org/martinapensalfini/ontologies/2022/9/stop#>
SELECT ?topic_name (COUNT(?unit) as ?number_of_songs)
WHERE {
?topic stop:appears_in ?unit.
?unit rdf:type stop:Song.
?topic stop:have_name ?topic_name.
}
GROUP BY ?topic
ORDER BY desc(?number_of_songs)
LIMIT 1
Result: Dream
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX stop: <http://www.semanticweb.org/martinapensalfini/ontologies/2022/9/stop#>
SELECT ?topic_name (COUNT(?unit) as ?number_of_poems)
WHERE {
?topic stop:appears_in ?unit.
?unit rdf:type stop:Poem.
?topic stop:have_name ?topic_name.
}
GROUP BY ?topic
ORDER BY desc(?number_of_poems)
LIMIT 1
Result: Religion
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX stop: <http://www.semanticweb.org/martinapensalfini/ontologies/2022/9/stop#>
SELECT ?topic_name
WHERE {
?unit rdf:type stop:Song;
stop:have_name "Un chimico"^^rdfs:Literal;
stop:is_about ?topic.
?topic stop:have_name ?topic_name.
}
Result: Devastation, Love, Nature, Salvation, Suffering
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX stop: <http://www.semanticweb.org/martinapensalfini/ontologies/2022/9/stop#>
SELECT ?topic_name
WHERE {
?unit rdf:type stop:Poem;
stop:have_name "Trainor, the druggist"^^rdfs:Literal;
stop:is_about ?topic.
?topic stop:have_name ?topic_name.
}
Result: Family, Marriage
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX stop: <http://www.semanticweb.org/martinapensalfini/ontologies/2022/9/stop#>
SELECT ?unit_name
WHERE {
VALUES ?type { stop:Poem stop:Song }
?unit rdf:type ?type;
stop:have_name ?unit_name;
stop:is_about stop:Sky.
}
Result: Dippold, The Optician; Fiddler Jones; Un ottico
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX stop: <http://www.semanticweb.org/martinapensalfini/ontologies/2022/9/stop#>
SELECT ?unit_name
WHERE {
VALUES ?type { stop:Poem stop:Song }
?unit rdf:type ?type;
stop:have_name ?unit_name;
stop:is_about stop:Love.
}
Result: Un chimico
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX stop: <http://www.semanticweb.org/martinapensalfini/ontologies/2022/9/stop#>
SELECT DISTINCT ?p_name
WHERE {
?song stop:have_name "La collina"^^rdfs:Literal;
stop:related_to ?poem.
?poem stop:has_character ?p_character.
?p_character stop:have_name ?p_name.
FILTER (NOT EXISTS {?song stop:has_character ?p_character})
}
Result: Aunt Emily, Edith, Major Walker, Sevigne Houghton, Towny Kincaid, Uncle Isaac
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX stop: <http://www.semanticweb.org/martinapensalfini/ontologies/2022/9/stop#>
SELECT ?poem_name
WHERE {
?unit stop:have_name "Un giudice"^^rdfs:Literal;
rdf:type stop:Song;
stop:related_to ?poem.
?poem stop:have_name ?poem_name.
}
Result: Judge Selah Lively