商业RDF三元组数据库AllegroGraph

商业RDF三元组数据库AllegroGraph

AllegroGraph是Franz公司开发的RDF三元组数据库。由于Franz公司有着深厚的人工智能背景,早期一直开发 Common Lisp 和 Prolog 语言的实现工具,这使得AllegroGraph 对语义推理功能具有较为完善的支持。AllegroGraph 除了三元组数据库的基本功能外,还支持动态物化的 RDFS++推理机、OWL2 RL 推理机、Prolog 规则推理系统、时空推理机制、社会网络分析库、可视化 RDF 图浏览器等。同时,AllegroGraph 支持Java、Python、C#、Ruby、Clojure/Scala、Lisp等多种语言的编程访问接口。图3-22所示为AllegroGraph的系统架构。

图3-22 AllegroGraph的系统架构

下面演示 AllegroGraph 的安装、RDF 知识图谱导入与 SPARQL 查询。从官方网站下载 AllegroGraph 服务器免费版(存储的 RDF 三元组数量不能超过500万条)。AllegroGraph要求操作系统为64位Linux。

步骤1。解压缩下载的安装包文件:

tar zxf agraph-6.4.1-linuxamd64.64.tar.gz。

解压缩后的目录为agraph-6.4.1。

步骤2。进入 agraph-6.4.1目录,执行安装脚本:install-agraph/home/xinwang/agraph。

将 AllegroGraph 安装到指定目录/home/xinwang/agraph 中。在安装过程中,需要回答一系列系统配置问题,作为测试环境,只需要输入两次管理员用户 super 的密码,对于其他问题直接按Enter键,接受默认值即可。

步骤3。执行脚本,启动AllegroGraph服务器:

/home/xinwang/agraph/bin/agraph-control--config/home/xinwang/agraph/lib/agraph.cfg start

输出如下,表示服务器启动成功:

Daemonizing...

Server started normally: Running with free license of 5,000,000 triples; no-expiration.

Access AGWebView at http://127.0.0.1:10035

步骤4。在浏览器中访问 http://127.0.0.1:10035,打开 AllegroGraph 服务器的 Web 管理界面AGWebView。以super身份登录。

步骤5。创建数据库。在“Create new repository”部分的“Name”文本框中输入testds,单击【Create】按钮创建数据库,如图3-23所示。

图3-23 AllegroGraph创建数据库

步骤6。导入RDF知识图谱。在“Repository testds”页面中,选择【Load and Delete Data】/【Import RDF】/【from an uploaded file】,在该页面上方出现选择RDF文件的对话框,在“File:”字段中浏览并选择 music_1000_triples.nt 文件,单击对话框右下方的【OK】按钮。

步骤7。查询知识图谱。选择页面上方菜单栏中的【Query】/【New】菜单项;转到【Edit query】页面,输入 SPARQL 查询,单击页面下方的【Execute】按钮执行查询,如图3-24所示,该查询的执行结果如图3-25(a)所示。单击查询结果中的第一个实体track_00001,得到以其为主语的全部三元组详细信息,如图3-25(b)所示。

图3-24 AllegroGraph执行SPARQL查询

图3-25 AllegroGraph执行SPARQL查询的结果

步骤8。执行脚本,停止AllegroGraph服务器:

/home/xinwang/agraph/bin/agraph-control--config/home/xinwang/agraph/lib/agraph.cfg stop。

原文地址:https://www.cnblogs.com/feifanrensheng/p/14463999.html