如何在ruby

编程入门 行业动态 更新时间:2024-10-24 06:36:32
本文介绍了如何在ruby-on-rails应用程序顶部使用dBpedia设置neo4j?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图将dBpedia与neo4j的neo4j一起使用.

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

假设我已经安装了 neo4j 并下载了 dBpedia数据集.

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的最简单方法是使用 dbpedia4neo 库.这是一个Java库,但是您不需要知道任何Java,因为您只需要运行可执行文件即可.

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.

  • https: //github/oleiade/dbpedia4neo/blob/master/src/main/java/org/acaro/dbpedia4neo/inserter/DBpediaLoader.java
  • https: //github/oleiade/dbpedia4neo/blob/master/src/main/java/org/acaro/dbpedia4neo/inserter/TripleHandler.java
  • github/oleiade/dbpedia4neo/blob/master/src/main/java/org/acaro/dbpedia4neo/inserter/DBpediaLoader.java
  • github/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 github/oleiade/dbpedia4neo.git $ cd dbpedia4neo

    (Oleiade的fork包含一个较小的蓝图更新,该更新确实sail.initialize();参见 groups.google/d/msg/gremlin-users/lfpNcOwZ49Y/WI91ae-UzKQJ ).

    (Oleiade's fork includes a minor Blueprints update that does sail.initialize(); See groups.google/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>oss.sonatype/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:

  • 直接使用JRuby和Blueprints-Neo4j API.
  • 使用常规的Ruby和 Rexster REST服务器,该服务器类似于Neo4j Server,不同之处在于它支持多个图形数据库.
  • Use JRuby and the Blueprints-Neo4j API directly.
  • 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.

    • bulbflow/
    • github/espeed/bulbs
    • github/espeed/bulbs/tree/master/灯泡/rexster
    • bulbflow/
    • github/espeed/bulbs
    • github/espeed/bulbs/tree/master/bulbs/rexster

    另一种方法是在Ruby中处理dbpedia RDF转储文件,写出与CSV文件的节点和关系,并使用 Neo4j批处理导入器以进行加载.但这需要您手动将RDF数据转换为Neo4j关系.

    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

    本文发布于:2023-10-25 22:15:55,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1528262.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:如何在   ruby

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!