首页 > 解决方案 > SPAQRL 创建排除查询

问题描述

我有这种结构


<ontology:Louvre>  
<rdf:type ontology:Museum/>
<ontology:preserves rdf:Gioconda/>
<ontology:locatedIn rdf:Paris/>
<ontology:name>Louvre</ontology:name>

<ontology:Gioconda>
<rdf:type ontology:Artwork/>
<ontology:preserved rdf:Louvre/>
<ontology:author rdf:Leonardo/>
<nomeOpera>Gioconda</nomeOpera>

<rdf:Leonardo_Da_Vinci>
<rdf:type ontology:Painter"/>
<ontology:paint ontology:Gioconda"/>
<ontology:paint ontology:Ultima_cena"/>
<name>Leonardo Da Vinci</name>

...(other museum, artist and artwork)
I use "ontology" to indicate my prefix

博物馆的专属艺术家有可能找回吗?

标签: sparqlontologydbpediaprotegesparqlwrapper

解决方案


我找到了解决方案。这是我正在寻找的查询

SELECT DISTINCT * WHERE {
   ?museum ontology:preserves ?artwork .
   ?museum ontology:name "Louvre" .
   ?artwork ontology:author ?author.
    FILTER NOT EXISTS{
        ?museum2 ontology:preserves ?artwork2 .
        ?artwork2 ontology:author ?author .
        FILTER (?museum2 != ?museum)
    }
}

推荐阅读