I have the following Python code. It basically returns some RDF elements from an online resource using SPARQL.
I want to query and return something from one of my local files. I tried to change it, but could not return anything.
What should I change for the request inside my local, not http://dbpedia.org/resource ?
from SPARQLWrapper import SPARQLWrapper, JSON # wrap the dbpedia SPARQL end-point endpoint = SPARQLWrapper("http://dbpedia.org/sparql") # set the query string endpoint.setQuery(""" PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX dbpr: <http://dbpedia.org/resource/> SELECT ?label WHERE { dbpr:Asturias rdfs:label ?label } """) # select the retur format (eg XML, JSON etc...) endpoint.setReturnFormat(JSON) # execute the query and convert into Python objects # Note: The JSON returned by the SPARQL endpoint is converted to nested Python dictionaries, so additional parsing is not required. results = endpoint.query().convert() # interpret the results: for res in results["results"]["bindings"] : print res['label']['value']
Thanks!
source share