RDFox学习笔记(01)

RDFox学习笔记

一、申请license

免费的license只发放个组织内部的人员,因此要用学校或组织的邮箱才可通过申请,不可以使用公共域的邮箱。

申请通过后,在邮箱内下载licences文件,存入可执行文件所在的路径中。

  1. 打开Windows DOS命令行,输入下列语句:

     RDFox.exe sandbox

    显示如下许可权限等信息:

    A new server connection was opened as role 'guest' and stored with name 'sc1'.

  2. 然后输入下列语句:

     > endpoint start

    显示如下信息:

    The REST endpoint was successfully started at port number/service name 12110 with 3 threads.

    即:REST 端点在端口号/服务名称 12110 上成功启动,有 3 个线程。

二、创建并激活数据库

指令:dstore、active

 > dstore create family
 A new data store 'family' was created and initialized.
 ​
 > active family
 Data store connection 'family' is active.

三、导入数据

指令:import+带后缀的数据文件名

数据文件存储的位置应该与RDFox可执行文件在同一个文件夹中。

 > import data.ttl
 //导入结果如下:
 Adding data in file 'data.ttl'.
 Import operation took 0.001 s.
 Processed 21 facts, of which 21 were updated.

四、运行查询

  1. 进行一个前置的输出设置

     set output out
  2. 定义一个前缀PREFIX

     > PREFIX : <https://oxfordsemantic.tech/RDFox/getting-started/>
     //将冒号作为前缀,代替上面尖括号里的内容,简化之后的输出形式
     Prefix name ':' was declared as <https://oxfordsemantic.tech/RDFox/getting-started/>.//已完成
  3. 开始第一个查询!

     > SELECT ?s?p?o WHERE {?s?p?o}
     ​
     //查询结果:
     //以@prefix开头的几行语句
     ​
     //数据中存储的内容
     //对于输出结果的统计信息

    在谓词位置的“rdf:type”代表的关系为:“实体所属的类型”。可以借此查询所有人名(所有属于人类的实体的名称。

     SELECT ?p ?n WHERE {?p rdf:type :Person . ?p :forename ?n}

    /Person、forename前面的冒号不可空格/

    原理大概为:找出所有属于Person的对象,存入p,然后输出所有与p有forename关系的属性。

    注意p与n的位置

  4. 使用SAPRQL插入数据

    通过查询修改数据内容。指令:INSERT

     INSERT {?x :marriedTO ?y} WHERE {?y :marriedTo ?x}

    执行结束后再进行一次对所有记录的查询,可发现原本21条记录增加至22条。将婚配的信息由原本的一条单向记录增加为两条互补的记录。

  5. 添加规则

    import ! [?p, :hasChild, ?c] :- [?c, :hasParent, ?p] .

    意思是:若p与c之间有“hasChild”关系,则添加一个p与c之间有“hasParent”关系的规则。逗号不可省略

    验证:SELECT ?p ?c WHERE { ?p :hasChild ?c }
  6. 删除事实(元组)

    指令:DELETE DATA

    DELETE DATA { :stewie :hasParent :lois}
    //删除一条孩子的父母信息
    
    //验证:
    SELECT ?p ?c WHERE {?p :hasChild ?c}

    结果显示,之前通过规则添加的stewie与lois之间的:hasParent关系被删除后,表中本来存在的两人之间的:hasChild关系也消失了,这是由于规则的约束作用

  7. 停用并重启RDF

    停用指令:quit

    沙盒模式下,程序关闭时所有的修改都将丢失。虽然不能保存结果,但是可以将本次所有对数据库的操作按顺序存入txt文件,修改文件名并修改后缀为“.rdfox”

    下次想接着本次的修改继续进行工作,只需再打开RDFox时载入该导航文件即可。

    >RDFox.exe sandbox . start

    注意:所有的符号和空格都要格外注意。大致的规则如下:

    英文句号、感叹号、SELECT、WHERE等表运算的运算符两侧都要空格。表属性的?、:等与属性之间不空格。

五、若要在Web端进行操作,先在本地开启RDFox服务,然后按照教程在Web端进行操作

基础的操作学习到此为一个阶段,后续还有大量的说明文档,继续学习。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ReFox XI+ for VFP9 and all older versions ComPro (CZ) Jan Brebera info@refox.net jan.brebera@email.cz Seven steps to install ReFox XI+ 1. download ReFox XI+ files • ReFox_INST - download and save the .zip archive to your local disk - do not unpack it directly from the browser 2. create new folder for ReFox (e.g. "C:\ReFox XI+") and unpack the archive. Attention: Some zip-extractors (incl. the WinXP internal one) do not set the time of created file correctly and running ReFox.exe fails with error message: xxxxxxxx – Program violation In this case please use another extractor e.g. WinZip, pkunzip or Total Commander internal unzip 3. run ReFox.setup.exe to install ReFox 4. fill out your details in the form fill out the field 'Serial Number' do not change the fields 'Activation Key', modify the fields 'User name' and 'Company' if necessary after clicking 'OK' ReFox prepares data for generating the full activation key: created data sample: see ReFox.~~~ and ReFox~~~.zip files in your ReFox folder 5. send the data for generating activation key please create and send the e-mail message now (this version can send the data automatically) copy the text of ReFox.~~~ to the e-mail message body and the file ReFox~~~.zip send as an attachement 6. wait for sending the activation key back this can take several hours depending on daytime 7. copy the new activation key to ReFox folder and run ReFox.exe again Copyright © 1992-2007 by Jan Brebera, ComPro (CZ) ReFox is a property of its author - Jan Brebera Jan Brebera is holder of all rights regarding ReFox
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值