How to import dbpedia into neo4j?

2019-05-10 01:11发布

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

3条回答
等我变得足够好
2楼-- · 2019-05-10 01:52

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.

查看更多
孤傲高冷的网名
3楼-- · 2019-05-10 02:12

You might get some help from this blog post: http://blog.acaro.org/entry/dbpedia4neo

查看更多
祖国的老花朵
4楼-- · 2019-05-10 02:13

This user has written a script for it:

https://github.com/knutwalker/dbpedia-neo4j

查看更多
登录 后发表回答