Is there a way to search for objects, knowing the subject without repeating all the records?
Answer: Yes. And you can use various mechanisms: (a) iteration with restriction; or (b) issue a SPARQL query.
(a) restricts the schedule and iterates
This solution uses the RDFLib triples function over the Graph object. See this link .
#Parse the file g = rdflib.Graph() g.parse("yourdata.nquads") subject = article = rdflib.term.URIRef("http://www.someuri.org/for/your/subject")
(b) issue a SPARQL query
A more standard solution using the SPARQL standard .
rdflib.plugin.register('sparql', rdflib.query.Processor, 'rdfextras.sparql.processor', 'Processor') rdflib.plugin.register('sparql', rdflib.query.Result, 'rdfextras.sparql.query', 'SPARQLQueryResult')
source share