So I know that in order to run SPARQL statements against a local ttl file I use rdflib. In order to run SPARQL statements against dbpedia I run Sparqlwrapper. But how do I do both? i.e. suppose I have a local ttl file and I want to leverage some of the online resources available.
So ... suppose I have the following local ttl
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://www.learningsparql.com/ns/demo#i93234>
foaf:nick "Dick" ;
foaf:givenname "Richard" ;
foaf:mbox "richard49@hotmail.com" ;
foaf:surname "Mutt" ;
foaf:workplaceHomepage <http://www.philamuseum.org/> ;
foaf:aimChatID "bridesbachelor" .
Then I create the following python program to execute a SPARQL query and print out more human readable versions of the properties
filename = "C:/DataStuff/SemanticOntology/LearningSPARQLExamples/ex050.ttl" interesting
import rdflib
g = rdflib.Graph()
result = g.parse(filename, format='ttl')
print(result)
query = """
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?propertyLabel ?value
WHERE
{
?s ?property ?value .
?property rdfs:label ?propertyLabel .
}
"""
results=g.query(query)
print('Results!')
for row in results:
print(row)
Which will return nothing because it isn't accessing dbpedia, and therefore doesn't know what rdfs:label is. I get that. But how do I tell it to?