限制列表上的 SPARQL 查询

SPARQL query on restriction list

我正在学习 SPARQL,需要一些关于查询的建议。

例子 ontology :

<owl:Class rdf:about="http://snomed.info/id/187903000">
    <owl:equivalentClass>
        <owl:Class>
            <owl:intersectionOf rdf:parseType="Collection">
                <rdf:Description rdf:about="http://snomed.info/id/187900002"/>
                <owl:Restriction>
                    <owl:onProperty rdf:resource="http://snomed.info/id/609096000"/>
                    <owl:someValuesFrom>
                        <owl:Class>
                            <owl:intersectionOf rdf:parseType="Collection">
                                <owl:Restriction>
                                    <owl:onProperty rdf:resource="http://snomed.info/id/116676008"/>
                                    <owl:someValuesFrom rdf:resource="http://snomed.info/id/367651003"/>
                                </owl:Restriction>
                                <owl:Restriction>
                                    <owl:onProperty rdf:resource="http://snomed.info/id/363698007"/>
                                    <owl:someValuesFrom rdf:resource="http://snomed.info/id/13881006"/>
                                </owl:Restriction>
                            </owl:intersectionOf>
                        </owl:Class>
                    </owl:someValuesFrom>
                </owl:Restriction>
            </owl:intersectionOf>
        </owl:Class>
    </owl:equivalentClass>
    <rdfs:subClassOf rdf:resource="http://snomed.info/id/126546006"/>
    <rdfs:subClassOf rdf:resource="http://snomed.info/id/363501002"/>
    <rdfs:subClassOf rdf:resource="http://snomed.info/id/448558006"/>
    <field:Description.term.en-us.preferred xml:lang="en">Malignant neoplasm of malar bone</field:Description.term.en-us.preferred>
    <rdfs:label xml:lang="en">Malignant neoplasm of malar bone (disorder)</rdfs:label>
</owl:Class>

我正在尝试检索 owl:someValuesFrom 中存在的 URI,具体取决于 owl:onProperty 中存在的 URI

我试过这个查询:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?subject ?fsn ?rs WHERE {
  ?subject rdfs:label ?fsn ;
  <http://snomed.info/id/116676008> ?rs .
}

遵循 post Sparql query on restriction list (Equivalent To) in protégé 的建议。但是这个 post 中给出的 2 个答案没有用。

您知道我的查询有什么问题吗? 感谢您的帮助!

对于可能有相同问题的人,AKSW 的回答真的很有帮助并且很有效!

所以我使用 Turtle 格式来表示我的 ontology :

@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ns0: <http://snomed.info/field/Description.term.en-us.> .

<http://snomed.info/id/187903000>
  a owl:Class ;
  owl:equivalentClass [
    a owl:Class ;
    owl:intersectionOf (
      <http://snomed.info/id/187900002>
      _:genid3
    )
  ] ;
  rdfs:subClassOf <http://snomed.info/id/126546006>, <http://snomed.info/id/363501002>, <http://snomed.info/id/448558006> ;
  ns0:preferred "Malignant neoplasm of malar bone"@en ;
  rdfs:label "Malignant neoplasm of malar bone (disorder)"@en .

_:genid3
  a owl:Restriction ;
  owl:onProperty <http://snomed.info/id/609096000> ;
  owl:someValuesFrom [
    a owl:Class ;
    owl:intersectionOf (
      _:genid6
      _:genid8
    )
  ] .

_:genid6
  a owl:Restriction ;
  owl:onProperty <http://snomed.info/id/116676008> ;
  owl:someValuesFrom <http://snomed.info/id/367651003> .

_:genid8
  a owl:Restriction ;
  owl:onProperty <http://snomed.info/id/363698007> ;
  owl:someValuesFrom <http://snomed.info/id/13881006> .

采用这种格式,查询方式显得更加简单。因此,如果我想检索 属性 http://snomed.info/id/363698007 的值,我需要使用以下查询:

PREFIX  rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT ?subject ?x WHERE {
  ?subject owl:equivalentClass/(owl:intersectionOf/rdf:rest+/rdf:first)*/owl:someValuesFrom/(owl:intersectionOf/rdf:rest*/rdf:first)* ?rs .
  ?rs owl:onProperty <http://snomed.info/id/363698007> ;
      owl:someValuesFrom ?x .
}

此查询将为您提供以下结果:

?subject : http://snomed.info/id/187903000
?x : http://snomed.info/id/13881006