如何在ruby-on-rails应用程序顶部使用dBpedia设置neo4j? [英] How to setup neo4j with dBpedia ontop of ruby-on-rails application?

查看:83
本文介绍了如何在ruby-on-rails应用程序顶部使用dBpedia设置neo4j?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将dBpedianeo4jneo4j一起使用.

I am trying to use dBpedia with neo4j ontop of ruby on rails.

假设我已经安装了 neo4j 并下载了

Assuming I have installed neo4j and downloaded one of the dBpedia datasets.

如何将dbpedia数据集导入到neo4j中?

How do I import the dbpedia dataset into neo4j ?

推荐答案

将dbpedia加载到Neo4j的最简单方法是使用

The simplest way to load dbpedia into Neo4j is to use the dbpedia4neo library. This is a Java library, but you don't need to know any Java because all you need to do is run the executable.

您可以根据需要在JRuby中重写它,但是常规Ruby无法使用,因为它依赖于 Blueprints ,没有Ruby等效的Java库.

You could rewrite this in JRuby if you want, but regular Ruby won't work because it relies on Blueprints, a Java library with no Ruby equivalent.

这是两个密钥文件,它们提供了加载过程.

Here are the two key files, which provide the loading procedure.

  1. https: //github.com/oleiade/dbpedia4neo/blob/master/src/main/java/org/acaro/dbpedia4neo/inserter/DBpediaLoader.java
  2. https: //github.com/oleiade/dbpedia4neo/blob/master/src/main/java/org/acaro/dbpedia4neo/inserter/TripleHandler.java
  1. https://github.com/oleiade/dbpedia4neo/blob/master/src/main/java/org/acaro/dbpedia4neo/inserter/DBpediaLoader.java
  2. https://github.com/oleiade/dbpedia4neo/blob/master/src/main/java/org/acaro/dbpedia4neo/inserter/TripleHandler.java

这是所涉及内容的描述.

蓝图将RDF数据转换为图形表示.要了解幕后情况,请参见蓝图帆计划:

Blueprints is translating the RDF data to a graph representation. To understand what's going on under the hood, see Blueprints Sail Ouplementation:

下载dbpedia转储文件后,您应该能够构建 dbpedia4neo Java库并运行它无需修改Java代码.

After you download the dbpedia dump files, you should be able to build the dbpedia4neo Java library and run it without modifying the Java code.

首先,克隆GitHub存储库的oleiade的fork并切换到dbpedia4neo目录:

First, clone the oleiade's fork of the GitHub repository and change to the dbpedia4neo directory:

$ git clone https://github.com/oleiade/dbpedia4neo.git
$ cd dbpedia4neo

(Oleiade的fork包含一个较小的蓝图更新,该更新确实sail.initialize();参见

(Oleiade's fork includes a minor Blueprints update that does sail.initialize(); See https://groups.google.com/d/msg/gremlin-users/lfpNcOwZ49Y/WI91ae-UzKQJ).

在构建它之前,您需要更新pom.xml以使用更多当前的Blueprints版本和当前的Blueprints存储库(Sonatype).

Before you build it, you will need to update the pom.xml to use more current Blueprints versions and the current Blueprints repository (Sonatype).

为此,请打开pom.xml,然后在dependencies部分的顶部,将所有TinkerPop蓝图版本从0.6更改为0.9.

To do this, open pom.xml and at the top of the dependencies section, change all of the TinkerPop Blueprints versions from 0.6 to 0.9.

在文件中时,将Sonatype存储库添加到文件末尾的repositories部分:

While you are in the file, add the Sonatype repository to the repositories section at the end of the file:

<repository>
  <id>sonatype-nexus-snapshots</id>
  <name>Sonatype Nexus Snapshots</name>
  <url>https://oss.sonatype.org/content/repositories/releases</url>
</repository>

保存文件,然后使用maven进行构建:

Save the file and then build it using maven:

$ mvn clean install

这将为您下载并安装所有依赖项,并在target目录中创建一个jar文件.

This will download and install all the dependencies for you and create a jar file in the target directory.

要加载dbpedia,请使用maven运行可执行文件:

To load dbpedia, use maven to run the executable:

$ mvn exec:java \
  -Dexec.mainClass=org.acaro.dbpedia4neo.inserter.DBpediaLoader \
  -Dexec.args="/path/to/dbpedia-dump.nt"

dbpedia转储很大,因此加载需要一段时间.

The dbpedia dump is large so this will take a while to load.

现在已加载数据,您可以通过以下两种方式之一访问图形:

Now that the data is loaded, you can access the graph in one of two ways:

  1. 直接使用JRuby和Blueprints-Neo4j API.
  2. 使用常规的Ruby和 Rexster REST服务器,该服务器类似于Neo4j Server,不同之处在于它支持多个图形数据库.
  1. Use JRuby and the Blueprints-Neo4j API directly.
  2. Use regular Ruby and the Rexster REST server, which is similar to Neo4j Server except that it supports multiple graph databases.

有关如何创建Rexster客户端的示例,请参见Bulbs,这是我编写的同时支持Neo4j Server和Rexster的Python框架.

For an example of how to create a Rexster client, see Bulbs, a Python framework I wrote that supports both Neo4j Server and Rexster.

  • http://bulbflow.com/
  • https://github.com/espeed/bulbs
  • https://github.com/espeed/bulbs/tree/master/bulbs/rexster

另一种方法是在Ruby中处理dbpedia RDF转储文件,写出与CSV文件的节点和关系,并使用

Another approach to all this would be to process the dbpedia RDF dump file in Ruby, write out the nodes and relationships to a CSV file, and use the Neo4j batch importer to load it. But this will require that you manually translate the RDF data into Neo4j relationships.

这篇关于如何在ruby-on-rails应用程序顶部使用dBpedia设置neo4j?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆