Using Jena reasoner on Neo4J db
Asked Answered
M

3

7

it's my first time writing here but i'm really struck with a problem: is it possible to use the Jena reasoner on a No-SQL database, like Neo4J, already filled with data?

I've a Neo4J's graph rappresenting a bunch of triples and I would like to use the Jena API and the Jena reasoner on them. I thought about using the SDB/TDB component of Jena but I don't get how to actually load the data into my model since the SDB component seems to work with just SQL databases and the go throught the whole TDB javadoc seems to be a bit too much. Should I define some kind of configuration file for the TDB model too ?

Thanks very much for the help.

Melodymeloid answered 8/4, 2014 at 10:51 Comment(4)
When you say you have a graph representing a bunch of triples...we need more detail on what that means. If you can get the data from Neo4J into a Jena "Model" then you should be able to reason over it. But there are big differences between the neo4j model and the jena model. Can you explain how you're turning neo4j nodes and relationships into RDF triples? That would help.Whitton
Thx for the answer, I was incorrect saying that they're a bunch of triples, cause I'm actually trying first with simple data (like the movie database example provided by Neo4J): the idea after that was to try to insert data throgh SPARQL query (I used Rexster to expose the neo4J database) turning it in an actual tripel store (or at least that was what i thought) When you talk about the difference about the 2 models can you point me to something or explain better what you mean ?Melodymeloid
Did you find something more about reasoning and Neo4j?Bedel
In the end I had to suck out all the data from my database and build a jena Model, so that i could use the inference methods from thereMelodymeloid
W
11

You should have a look at this link which describes the connection between neo4j and triplestores. Or possible connections at least.

The neo4j model is very different than the RDF model, which Jena uses. RDF is composed of triples, meaning subjects, predicates, and objects. Here is an example of a graph composed of triples. Note the use of URIs for identifying resources, and note that the nodes are typically atomic data values. They're a URI, a simple number, a string, and so on.

In Neo4j, nodes are "Property Containers". Meaning that they're not just URIs, but they're actually bundles of information. Relationships connect nodes. So RDF "predicates" are sort of like Neo4j relationships, but neo4j nodes are not like RDF resources and literals.

Your main task if you want to use reasoners over a neo4j database is going to be to suck data out of neo4j, and format it as a set of RDF triples. You can then put those RDF triples into a Jena Model. When you have that jena model in memory, you can use existing jena APIs to use reasoners with that model.

Whitton answered 8/4, 2014 at 13:17 Comment(1)
Tyvm for the explanation, I will then try to investigate more the rappresentation of RDF triple via Neo4J and see if I can come up with something, otherwise i'll try to suck the data out of the neo4j database manuallyMelodymeloid
C
1

I'm a bit late to the party but you can use https://github.com/neo4j-labs/neosemantics to output the Neo4J data into triples and read that into a Jena Model

Challah answered 22/3, 2021 at 22:1 Comment(0)
L
0

I am in the process of creating a neo4j implementation of the jena API. For this I am subclassing ObjectProperty, Individual and OntClass and implement queries to the neo4j endpoint.

The main problem is that for reasoning the whole database must be loaded in memory in order to use Jena's inmemory reasoning. My solution at the moment is to use a "reasoning"-server to process this and write new results to the main persistence layer. This, of course, is only suitable for long term recommendation systems and not for UI interactions.

Have a look here for the current state of the project:

https://github.com/uzuzjmd/Wissensmodellierung

Path: competence-database\src\main\scala\uzuzjmd\competence\persistence\neo4j

Anyone interested to participate in this open source project feel free to contact me.

Laywoman answered 5/1, 2016 at 12:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.