GraphDB用OWL2-RL推理前将命名图三元组复制到nil图,如何避免?
问题:GraphDB推理引擎将命名图三元组复制到nil图的异常行为
这是我在本论坛的第一个问题,若有疏漏请见谅。我发现GraphDB的推理引擎会将命名图中的所有三元组复制到nil图中,之后仅在nil图内进行推理,这似乎并非正确的推理处理方式。
示例数据
INSERT DATA { :Dog rdfs:subClassOf :Mammal. GRAPH :G1 { :Lassie a :Dog. } }
过滤查询语句
我使用OWL2-RL规则集进行推理,开启推理后查询返回805条语句,通过以下过滤查询:
SELECT * WHERE { { { GRAPH ?g { ?s ?p ?o. } } UNION { GRAPH <http://rdf4j.org/schema/rdf4j#nil> { ?s ?p ?o. } BIND ("-" AS ?g) } } FILTER ( !( strstarts(str(?s), "http://www.w3.org/2002/07/owl#") || strstarts(str(?s), "http://www.w3.org/2000/01/rdf-schema#") || strstarts(str(?s), "http://www.w3.org/2001/XMLSchema#") || strstarts(str(?s), "http://www.w3.org/1999/02/22-rdf-syntax-ns#") || strstarts(str(?o), "http://www.w3.org/2002/07/owl#Thing") || false )) }
查询结果
得到9条语句,其中:Lassie a :Dog.出现两次:
| g | s | p | o |
|---|---|---|---|
| :G1 | :Lassie | rdf:type | :Dog |
| "-" | :Lassie | rdf:type | :Dog |
(UNION分支中的BIND ("-" as ?g)是为了确保“-”结果确实来自nil图,而非SPARQL查询的伪影)
目前存在两条:Lassie a :Dog.语句,一条在:G1图,一条在nil图。关闭推理后仅能看到原始语句,说明nil图中的该语句是推理生成的,但我在builtin_owl2-rl.pie文件中找不到控制该推理的规则。请问是否可以阻止nil图中生成该语句,或在规则集中启停该行为?
Proof插件的问题
另外,Proof插件也无法提供帮助,因为proof:explain仅支持三个参数,无法指定待验证语句的上下文,导致它两次错误返回:Lassie a :Dog.为显式语句。
验证查询语句
PREFIX proof: <http://www.ontotext.com/proof/> SELECT * WHERE { { GRAPH ?g { ?s ?p ?o. } } UNION { GRAPH <http://rdf4j.org/schema/rdf4j#nil> { ?s ?p ?o. } BIND ("-" AS ?g) } FILTER ( !( strstarts(str(?s), "http://www.w3.org/2002/07/owl#") || strstarts(str(?s), "http://www.w3.org/2000/01/rdf-schema#") || strstarts(str(?s), "http://www.w3.org/2001/XMLSchema#") || strstarts(str(?s), "http://www.w3.org/1999/02/22-rdf-syntax-ns#") || strstarts(str(?o), "http://www.w3.org/2002/07/owl#Thing") || false )) ?ctx proof:explain (?s ?p ?o) . ?ctx proof:rule ?rule . }
验证结果
| g | s | p | o | ctx | rule |
|---|---|---|---|---|---|
| :G1 | :Lassie | rdf:type | :Dog | _:8017b441a12c4c6eab8466163d0587c7154718 | "explicit" |
| "-" | :Lassie | rdf:type | :Dog | _:8017b441a12c4c6eab8466163d0587c7154719 | "explicit" |
内容的提问来源于stack exchange,提问作者almotasim
相关产品推荐
相关产品推荐

