Adding reasoning to dgraph

Hi,
I was chatting with @MichelDiz on Slack and he told me it could be a good topic to post here.
I was wondering if there was a way or any plan to add a reasoner on dgraph to infer results and classes of objects and especially to requests things without the full knowledge of the existing relations.

Thanks!

2 Likes

Hey Shazz, can you share the links you have mentioned as examples?

Yes of course. I coded a little example using owlready2 which use Pellet as an OWL Reasoner.
It demonstrates how relations are inferred and also how classes of objects are inferred.
Then, using SPARQL it shows how to query objects without the full knowledge of the ontology and for example to solve queries like: Give me the Cities in a Country without knowing a City could be in different graphs under a Country.

If the code is not clear… just ask!

Code: Owlready2_sandbox/country_example.py at master · shazz/Owlready2_sandbox · GitHub

Okay, thanks for the example.

Well, researching about OWL Reasoner. It is an engine that interprets data from a source with RDF standards (or others) based on ontology references. Right?

Chatting with @michaelcompton we get to a short answer about this, that is that no we aren’t planning on doing anything like that. (But We can track this for future features, just open a ticket in Github referencing this discussion). But gathering information about that is very important to guide engineers.

One point I must comment on, is the fact that Dgraph does not work with RDF standardized by the W3C. Our RDF is very basic using a simple set of triples. Therefore, there would be no direct alignment between Dgraph and any other type of reasoner that uses RDF as a standard at principle.

That is, Dgraph is not an RDF triple store. It is a native GraphDB that stores the whole structure in BadgerDB. RDF has been used in the past to make things easier. But JSON is kind of our standard today (RDF is not deprecated tho).

Some things like prefixes (you can use Get started with Dgraph for prefixes, but it is totally different from what W3C does) and other ontology features need to be customized (I think it would be possible, but it would not be easy). Create a reasoner in the context of Dgraph, it would be necessary to study an algorithm and perhaps introduce a new way of making queries. However, by my experience using Dgraph, and for talking to @michaelcompton. We believe that it is possible to virtualize something similar to what a Reasoner does using our query system and creating an external “driver/application” for it.

A few questions about that, so future readers who come to read this discussion be in sync.

1 - What does a Reasoner solve? what does it do better than Dgraph is not able to solve today?

I remember you introduced the topic “Reasoner” because your query wasn’t great. And some statements needed to be hand-coded in the query.

1.1 - What is the general use of a reasoner for the modern web? (For example, outside the Academy - I know that those engines are heavily used in Universities and so on, not sure if it is used in modern web. That’s a thing that I personally would like to know).

2 - Do you have any idea how it would work in the context of Dgraph? what it would take and etc (I have shared a slight idea above, but if you have something to add. Please do).

3 - Reasoning needs semantics. We can simulate semantics with intermediate nodes or maybe facets. Is a simulation ok for you?

Still, I think it would be complicated to support this natively as most DBs that use reasoners do. Things like Add classes and etc natively. It would be easier to create an external application for now.

@michaelcompton has analyzed your code. And found that the semantics is in the schema. So that would be possible to simulate in Dgraph.

Cheers.

Add a ref:

Apache Jena http://jena.apache.org/documentation/inference/index.html
has some API for reasoning.
In theory, only need to make an implementation of InfGraph in dgraph.
Then the reason engine will works.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.