具有增量变量的SPARQL空白节点简化

问题描述

我正在尝试使用标识符的增量变量在图形上执行Blank节点简化,但是urn:count对象没有更新。

到目前为止,我有以下代码

PREFIX :    <http://example.com/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>


####################
# Create Counter Graph #
####################

INSERT DATA {
    graph <urn:counters> {<urn:Example> <urn:count> 1 }
}
;


####################
# Rewrite objects #
####################

DELETE {
    #remove the old value of the counter
    graph <urn:counters> {<urn:Example> <urn:count> ?old}
  ?s ?p ?bnode .
}
INSERT {
    #update the new value of the counter
    graph <urn:counters> {<urn:Example> <urn:count> ?new}
  
  ?s ?p ?iri .
  GRAPH :aliases {
    ?bnode owl:sameAs ?iri .
  }
}
WHERE {
  {
    SELECT ?bnode ?iri ?new ?old
    WHERE {

      {        
        SELECT disTINCT ?bnode
        WHERE {
          [] ?p ?bnode .
          FILTER isBlank(?bnode)
        }
      } 
                # retrieve the counter
    graph <urn:counters> {<urn:Example> <urn:count> ?old}
    
    
    # compute the new value
    bind(?old+1 as ?new)  
    
    
    #construct the IRI
    bind(IRI(concat("http://example.org/item/",str(?old))) as ?iri) 
    }
  }
    ?s ?p ?bnode .
}
;

将产生以下输出

<#TripleMap1>
        rr:logicalTable        <http://example.org/item/1> ;
        rr:predicateObjectMap  <http://example.org/item/1> ;
        rr:subjectMap          <http://example.org/item/1> .

但是我希望输出如下。

<#TripleMap1>
        rr:logicalTable        <http://example.org/item/1> ;
        rr:predicateObjectMap  <http://example.org/item/2> ;
        rr:subjectMap          <http://example.org/item/3> .

输入图如下。

@prefix rr:    <http://www.w3.org/ns/r2rml#> .
<#TripleMap1>
        rr:logicalTable        [] ;
        rr:predicateObjectMap  [];
        rr:subjectMap []; 

任何帮助将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...