I have an ontology and I want tp perform some advanced SPARQL queries on it using Apache Jena Fuseki over a Google Collab environment, is it possible?
I tried this code in my local device and it's working, however I want to work in google collab.
!pip install sparqlwrapper
from SPARQLWrapper import SPARQLWrapper, JSON
sparql = SPARQLWrapper(
'http://localhost:3030/Quran/sparql'
)
sparql.setReturnFormat(JSON)
sparql.setQuery("""
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX qur: <http://quranontology.com/Resource/>
SELECT distinct ?prophetLabel
WHERE {
?verse2 rdf:type qur:Verse.
?verse2 rdfs:label ?textSimple2.
?word rdf:type qur:Word.
?word qur:IsPartOf ?verse2.
?letter rdf:type qur:PronounRefDifferentVerse.
?letter qur:IsPartOf ?word.
?verse rdf:type qur:Verse.
?person rdfs:subClassOf* qur:Person.
?prophet rdf:type ?person.
?prophet rdfs:label ?prophetLabel.
?prophet qur:MentionedIn ?verse.
?letter qur:ReferToVerse ?verse.
FILTER (REGEX(STR(?textSimple2), 'برا بوالديه' ,"i")).
}
"""
)
try:
ret = sparql.queryAndConvert()
for r in ret["results"]["bindings"]:
print(r)
except Exception as e:
print(e)
Using the same code in google collab, gives me this error:
<urlopen error [Errno 99] Cannot assign requested address>