Re: Create dinamically SPARQL query and work with the result as owlready object
Posted by Jiba on Mar 03, 2019; 11:58am
URL: http://owlready.306.s1.nabble.com/Create-dinamically-SPARQL-query-and-work-with-the-result-as-owlready-object-tp863p865.html
Hi,
you can use the IRI of entities in SPARQL queries. IRI must be put inside <> in SPARQL, for example :
Query = ’’’PREFIX...SELECT ?owner WHERE {?owner :has_bought <’’’ +car.iri +”>.}”
where car is an Owlready individual.
Then you can execute the query:
results = default_world.as_rdflib_graph().query_owlready(Query)
results is a generator yielding the results of the query (here individuals). You can make a for loop over results, of transform it in a list as follows:
results = list(results)
print(results)
Best regards,
Jiba