Closed yazoo178 closed 2 years ago
Although rdflib does not support inference, inference is done on our end, and is requested through the "inference" parameter. In this case, the sparqlwrapper package only uses rdflib for parsing the results. If you need inference, then after you instantiate your object, you can use the method addCustomParameter
as follows:
from SPARQLWrapper import SPARQLWrapper, JSON
q = """
... your query ...
"""
sparql = SPARQLWrapper('https://id.nlm.nih.gov/mesh/sparql')
sparql.addCustomParameter('inference', 'true')
sparql.setQuery(q)
sparql.setReturnFormat(JSON)
results = sparql.query().results()
print(results)
PS - it will be helpful if in future you use Github embedded code blocks (as I do above), rather than embedding an image from a Jupyter Notebook. If you still have trouble, I will need your query as text rather than an image to help :)
Given your thumbs up - I will close.
I'm having a difficult time trying to run the SPAQL query examples outside of the demo environment provided on the webpage.
I suspect the has something to do with RDFS inference? flag == True, as I am unable to select this option when running the queries in a python environment.
The result set is empty in my case, but for the same online example the result set contains over 50 results.