用Fuseki,TDB和命名图进行推理? [英] Reasoning with Fuseki, TDB and named graphs?

查看:100
本文介绍了用Fuseki,TDB和命名图进行推理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Fuseki 2中的TDB数据集提供一个包含10-20个命名图的数据集. 我想使用推理器对我的数据进行推断.我想看到的行为是,在每个图中推断出的三元组应出现在这些图中(尽管如果三元组也出现在默认图中也可以). 有没有简单的配置方法?我还没有找到与我想要的配置相匹配的配置示例.

I'm serving a dataset containing 10-20 named graphs from a TDB dataset in Fuseki 2. I'd like to use a reasoner to do inference on my data. The behaviour I'd like to see is that triples inferred within each graph should appear within those graphs (although it would be fine if the triples appear in the default graph too). Is there a simple way of configuring this? I haven't found any configuration examples that match what I am trying to do.

我尝试过的配置与以下标准示例非常相似.

The configuration I've tried is very similar to the following standard example.

DatasetTDB-> GraphTDB-> InfModel-> RDFDataset

DatasetTDB -> GraphTDB -> InfModel -> RDFDataset

我看到的数据的最终视图只是数据的很小一部分(似乎所有命名的图都沿着该管道放置在某个地方,只剩下很小的默认图). 使用tdb:unionDefaultGraph似乎对此没有影响.

The final view of the data I see is only a very tiny subset of the data (it appears that all the named graphs are dropped somewhere along this pipeline, and only the tiny default graph is left). Using tdb:unionDefaultGraph seems to have no effect on this.

prefix :        <#> .
@prefix fuseki:  <http://jena.apache.org/fuseki#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .

# Example of a data service with SPARQL query and update on an 
# inference model.  Data is taken from TDB.

## ---------------------------------------------------------------
## Service with only SPARQL query on an inference model.
## Inference model base data is in TDB.

<#service2>  rdf:type fuseki:Service ;
fuseki:name              "inf" ;             # http://host/inf
fuseki:serviceQuery      "sparql" ;          # SPARQL query service
fuseki:serviceUpdate     "update" ;
fuseki:dataset           <#dataset> ;
.

<#dataset> rdf:type       ja:RDFDataset ;
ja:defaultGraph       <#model_inf> ;
 .

<#model_inf> a ja:InfModel ;
 ja:baseModel <#tdbGraph> ;
 ja:reasoner [
     ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
 ] .

## Base data in TDB.
<#tdbDataset> rdf:type tdb:DatasetTDB ;
tdb:location "DB" ;
# If the unionDefaultGraph is used, then the "update" service should be removed.
# tdb:unionDefaultGraph true ;
.

<#tdbGraph> rdf:type tdb:GraphTDB ;
tdb:dataset <#tdbDataset> .
</code>

有人对此有任何想法吗?

Does anyone have any thoughts on this?

此外,如果有办法使数据集可写,则可以加分. (在某种程度上,我想做的是采用Owlim/GraphDB的默认行为,该行为保留持久的命名图,进行推理并允许更新.)

Also, bonus points if there's a way to make the dataset writable. (On some level, what I'm trying to do is approach the default behaviour of Owlim/GraphDB, which keeps persistent named graphs, does inferencing, and also allows for updates.)

谢谢.

推荐答案

我在代码中面临(或面临)相同的问题,但是我有部分解决方案.不幸的是,评论中提供的链接并不能真正解决我仍然面临的问题,但这可以部分解决问题.

I'm facing (or faced) the same problems on my code, but I have a partial solution. Unfortunately the link provided in the comments did not really help the issues I'm still facing, but this answers part of the problem.

我看到的数据的最终视图只是其中很小一部分 数据(似乎所有已命名的图都沿着 这个管道,只剩下很小的默认图).使用 tdb:unionDefaultGraph似乎对此没有影响.

The final view of the data I see is only a very tiny subset of the data (it appears that all the named graphs are dropped somewhere along this pipeline, and only the tiny default graph is left). Using tdb:unionDefaultGraph seems to have no effect on this.

为此我找到的解决方法是在配置文件中显式注册"您的命名图.我真的不知道这是否是最好的方法(也没有找到有关此确切上下文的任何文档或示例).在我的设置(Fuseki 2.4)上的一个工作示例:

The workaround I found for this is to explicitly 'register' your named graphs in the configuration file. I don't really know if it is the best way (and did not found any documentation or example for this exact context). A working example on my setup (Fuseki 2.4):

[usual configuration start]

# TDB Dataset
:tdb_dataset_readwrite
        a             tdb:DatasetTDB ;
        tdb:unionDefaultGraph true ; 
        #if you want all data to available in the default graph
        #without 'FROM-NAMing them' in the SPARQL query
        tdb:location  "your/dataset/path" .

# Underlying RDF Dataset
<#dataset> 
    rdf:type    ja:RDFDataset ;
    ja:defaultGraph <#model> ;
    ja:namedGraph [
        ja:graphName    <your/graph/URI> ;
        ja:graph        <#graphVar> 
    ] ;

    [repeat for other named graphs]
    .      


######
# Default Model : Inference rules (OWL, here)
<#model> a ja:InfModel;
    ja:baseModel <#tdbGraph>;
    ja:reasoner
    [ ja:reasonerURL 
        <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
    ]
    .

# Graph for the default Model
<#tdbGraph> rdf:type tdb:GraphTDB;
    tdb:dataset :tdb_dataset_readwrite .

######
# Named Graph
<#graphVar> rdf:type tdb:GraphTDB ;
    tdb:dataset :tdb_dataset_readwrite ;
    tdb:graphName <your/graph/URI> 
    .

然后,您可以运行这样的查询

Then, you can run a query like this one

[prefixes]

SELECT ?graph ?predicate ?object
WHERE {
  GRAPH ?graph {[a specific entity identifier] ?predicate ?object}
}
LIMIT 50

它将显示(在这种情况下)属性和值,以及在其中找到它们的源图.

And it will display (in this case) properties and values, and the source graph where they were found.

BUT:在此示例中,即使默认图应该导入推理规则(应全局应用,尤其是由于启用了unionDefaultGraph参数),也不会以交叉图"方式应用它们,即我仍然面临的问题.

BUT: in this example, even if the default graph supposedly imported inference rules (that should be applied globally, especially since the unionDefaultGraph parameter is enabled), they are not applied in a "cross-graph" manner, and that is the problem I am still facing.

通常,如果您将推理引擎添加到每个图形,这应该可以工作,根据Andy Seaborne的帖子

Normally, if you add the inference engine to every graph, this should work, according to Andy Seaborne's post here, but it doesn't work in my case.

希望这还是有帮助的.

Hope this helps nevertheless.

这篇关于用Fuseki,TDB和命名图进行推理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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