How to import dbpedia into neo4j? [closed]

怎甘沉沦 提交于 2019-12-07 15:12:28

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/7645884/how-to-import-dbpedia-into-neo4j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!