Import RDF (XML or Turtle) into Neo4j

12,293

Solution 1

If by importer you mean an executable to which you can pass an RDF file as a parameter, then no, as far as I know. You will have to write code, but probably not very much.

Your best bet is probably to read the Neo4j Linked Data pages, specifically the blog posts by Michael Bach about importing Turtle Ontologies and Stefanie Wiegand about OWL in Neo4j.

Since you mention Blueprints, you may want to look at using Sesame and Sail. You should be able to treat Neo4j as a triple store and achieve a convenient interface uniformity with your Freebase triple store. See dbpedia4neo for an example of how this is used for importing DBPedia dumps, your situation should be analogous.

You indicate that you have trouble parsing the Freebase data, however. If your data is corrupt, you will have to handle that regardless of how you choose to interact with Neo4j. I've had good experiences with Jena's Models, both the default and ontology ones, for various projects, and I'm not sure why you think they shouldn't be used. Is it possible that what you need is to tweak the importer that you have already written, rather than a new approach altogether?

Solution 2

There is a plugin that allows you to import RDF-Data into Neo4j. You simply put the semantics.liteOntoImport.jar-File into your plugin folder and in Neo4j command line you call:

CALL semantics.liteOntoImport('file:///filename.owl','RDF/XML')

Therefore your file should be in the import directory of Neo4j. If it is not you should enter the full path.

EDIT

Same procedure works for .xml and .ttl files, just change the type of the file in the command line (second argument) e.g. 'TURTLE'.

Solution 3

You can try the following in order to import database into neo4j.

First convert your database into csv files and import it into Gephi - a graph visualization tool. Then by using the Gephi plugin for neo4j database support, you should be able to export your database (from Gephi) into neo4j format.

Finally just copy the exported file into appropriate neo4j directory.

For importing database into Gephi, you will need two csv files - one with all the nodes and other with all the relationships. Follow this tutorial : http://blog.neo4j.org/2013/01/fun-with-beer-and-graphs.html

Get Gephi from here: https://gephi.org/

Get the Plugin from here : https://marketplace.gephi.org/plugin/neo4j-graph-database-support/

Hope this helps.

Share:
12,293
Mulgard
Author by

Mulgard

Updated on July 08, 2022

Comments

  • Mulgard
    Mulgard almost 2 years

    i downloaded the Database dump of Freebase. The format of the file is rdf turtle. I need to get all the data into the neo4j database.

    I already wrote an importer with help of tinkerpop.blueprints. First it seemed to work but after 30 minutes of importing an exception occured because the rdf file contained characters at positions where they are not allowed to be. A little bit later (after some investigation) i found out that the jena parser i used (RDFReader) is deprecated and shouldnt be used.

    What i need to know now:

    Is there any way to import that rdf file into neo4j? Jena is able to transform the data into seven different file formats: .ttl, .rdf, .ne, .jsonld, .owl, .trig, .nq.

    Is there an importer for one (or more) of these file formats?

  • mvladk
    mvladk about 10 years
    1. Neo4j Linked Data leads to broken link and github project without any documentation. 2. "importing DBPedia dumps, your situation should be analogous" - so I understand no one did it before and there is no direct way? 3. Why this answer was accepted?