Search code examples
pythonprologtriplestoreallegrograph

OWL reasoning in Prolog query from AllegroGraph Python API


I noticed that in the AllegroGraph Python API tutorial here, whenever they want to use OWL reasoning they use the conn.getStatements method instead of issuing a Prolog or SPARQL query. Is it possible to get triples inferred from the OWL reasoner by issuing a Prolog or SPARQL query instead of using the conn.getStatements method? I tried a Prolog query:

(select (?x ?y) (q ?x !ex:owned-by ?y))

where I had defined owned-by as owl:inverseOf ex:owns and had the triple ex:someone ex:owns ex:something in my store, and I got no results. I do get results from using conn.getStatements, so am I missing something essential in the Prolog query?


Solution

  • Did you call setIncludeInferred on the query object returned from prepareTupleQuery before calling evaluate?

    http://www.franz.com/agraph/support/documentation/v4/python-tutorial/python-API-40.html#Query%20Class

    IncludeInferred is False by default. I believe valid values are false (no reasoning), "rdfs++" or True, and "restriction", as mentioned in the HTTP rest documentation for the infer http query parameter. The Python implementation just passes the value through.

    http://www.franz.com/agraph/support/documentation/v4/http-protocol.html#header2-364