3

I need to import dbpedia into neo4j. I download the dbpedia from here: http://wiki.dbpedia.org/Downloads37 Any idea?

  • You may find this community answer useful: http://stackoverflow.com/questions/12212015/how-to-setup-neo4j-with-dbpedia-ontop-of-ruby-on-rails – 0x90 Apr 06 '13 at 06:19
  • Also, I know Kenny Bastiani did some work in this area. This seems to be a relevant project: https://github.com/kbastani/neo4j-dbpedia-importer – Brian Underwood Mar 10 '15 at 14:24
  • See [this userscript](https://github.com/knutwalker/dbpedia-neo4j) posted by user @Will Tachau. – cs95 Jul 20 '19 at 05:49
  • You might get some help from this blog post: http://blog.acaro.org/entry/dbpedia4neo – nawroth Oct 05 '11 at 09:38

1 Answers1

0

I am currently doing the same thing. I found that the biggest problem for this is the indexing so the best solution is to write a java program that extracts the statements with md5 hashes into a triple file like follows: subjectHash \t predicateHash \t objectHash \t subject \t predicate \t object \n.

In another file you will need to store the nodes (aka subjects and objects of statements): nodeHash \t nodeValue

The code for this procedure can be downloaded from my github: https://github.com/eschleining/DbPediaImport.git

Compile it with mvn package and it creates a jar file in target that takes the gzipped dbpedia files as arguments. If you only have the bz2 files you can transform them like follows: for i in *.bz2 ; do bzcat "$i" | gzip > "${i%.bz2}.gz"; done &

Now run: java -jar ConcurrentDataTableWriter-0.0.1-SNAPSHOT.jar yourdbpediaFolder/*.gz

Then you sort the newly created files manually with the sort utility of linux: gunzip -c nodes.gz | sort -k2 -u | gzip > nodes_unique.gz

And the triples file: gunzip -c triples.gz | sort -k1,3,2 -u | gzip > triples_unique.gz

Now you can compile the batch inserter of my repo with maven3 (mvn package) and run it in the same directory as the nodes_unique.gz and triples_unique.gz files it creates a Neo4J database directory named "DbpediaNe04J" (mind the typo "0 instead of o).

I found this to be the fastest way since it only looks up an index once for each subject/object pair in a triple.

Feel free to add datatype nodes as properties and so on. I currently have implemented each triple as a relationship between two nodes.

pNRuag
  • 63
  • 5