It was not exactly that (I omitted the unnecessary mess), but the flow is the same:
import rdflib
graph = rdflib.Graph()
person_ns = rdflib.URIRef('
http://dbpedia.org/ontology/Person')
object_ns = rdflib.URIRef('
http://dbpedia.org/ontology/Place')
organisation_ns = rdflib.URIRef('
http://dbpedia.org/ontology/Organisation')
resource = rdflib.URIRef("
http://dbpedia.org/resource/Adam Małysz")
graph.value(resource, rdflib.RDFS.label)
graph.load(resource) # << error here
for subject, predicate, object_ in graph:
if subject == resource and object_ in [person_ns, object_ns, organisation_ns]:
response += [
{
'serie': serie,
'subject': u''.join(subject).encode('utf-8'),
'predicate': u''.join(predicate).encode('utf-8'),
'type': u''.join(object_).encode('utf-8')
}
]
break
return response
Later, the sparql.setQuery(..) way worked for my friend.