SPARQL select 个剩余的三元组
SPARQL select remaining triples
我有一个 RDF 图,其中包含使用不同本体描述的数据(想想 VCARD 和 FOAF)。
现在为了使我的查询更简单,我想构建一个新图,在其中我将一个 ontology 映射到另一个,以便在一个 ontology.[=13= 中描述数据]
我已经弄清楚了映射部分,但我正在寻找的是 select 'remaining triples' 的方法,即已经在正确 [=30= 中的那些]
(因为这些在映射后应该保持不变)。
我认为应该有一种方法可以通过否定来做到这一点,但我似乎无法弄清楚。
例如,假设我有以下 RDF 图:
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@base <http://example.org/>
<somePerson>
a foaf:Person .
<someOtherPerson>
a vcard:Individual .
# [Some more triples]
我想将其映射到:
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@base <http://example.org/>
<somePerson>
a foaf:Person .
<someOtherPerson>
a foaf:Person.
# [Some more triples]
不使用 VCARD 来描述数据。
从第一个到第二个的映射非常简单,但我正在寻找一种保持其他三元组不变的简单方法。 (基本上将它们复制到输出)。
正如@UninformedUser 所建议的,这个查询结构可以解决问题。
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix foaf: <http://xmlns.com/foaf/0.1/>
prefix vcard: <http://www.w3.org/2006/vcard/ns#>
CONSTRUCT {
?name rdf:type foaf:Person .
?x ?y ?z .
}
WHERE {
{
{
?x ?y ?z .
}
FILTER NOT EXISTS
{
?x rdf:type vcard:Individual .
}
}
UNION
{
?name rdf:type vcard:Individual .
}
}
从这里开始:
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@base <http://example.org/>
<somePerson>
a foaf:Person .
<someOtherPerson>
a vcard:Individual .
[Some more triples]
到这里:
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@base <http://example.org/>
<somePerson>
a foaf:Person .
<someOtherPerson>
a foaf:Person.
[Some more triples]
我有一个 RDF 图,其中包含使用不同本体描述的数据(想想 VCARD 和 FOAF)。
现在为了使我的查询更简单,我想构建一个新图,在其中我将一个 ontology 映射到另一个,以便在一个 ontology.[=13= 中描述数据]
我已经弄清楚了映射部分,但我正在寻找的是 select 'remaining triples' 的方法,即已经在正确 [=30= 中的那些] (因为这些在映射后应该保持不变)。
我认为应该有一种方法可以通过否定来做到这一点,但我似乎无法弄清楚。
例如,假设我有以下 RDF 图:
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@base <http://example.org/>
<somePerson>
a foaf:Person .
<someOtherPerson>
a vcard:Individual .
# [Some more triples]
我想将其映射到:
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@base <http://example.org/>
<somePerson>
a foaf:Person .
<someOtherPerson>
a foaf:Person.
# [Some more triples]
不使用 VCARD 来描述数据。
从第一个到第二个的映射非常简单,但我正在寻找一种保持其他三元组不变的简单方法。 (基本上将它们复制到输出)。
正如@UninformedUser 所建议的,这个查询结构可以解决问题。
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix foaf: <http://xmlns.com/foaf/0.1/>
prefix vcard: <http://www.w3.org/2006/vcard/ns#>
CONSTRUCT {
?name rdf:type foaf:Person .
?x ?y ?z .
}
WHERE {
{
{
?x ?y ?z .
}
FILTER NOT EXISTS
{
?x rdf:type vcard:Individual .
}
}
UNION
{
?name rdf:type vcard:Individual .
}
}
从这里开始:
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@base <http://example.org/>
<somePerson>
a foaf:Person .
<someOtherPerson>
a vcard:Individual .
[Some more triples]
到这里:
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@base <http://example.org/>
<somePerson>
a foaf:Person .
<someOtherPerson>
a foaf:Person.
[Some more triples]