鑑於數據像這樣(在RDF/XML):
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:pizzas="http://example.org/pizzas#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://example.org/pizzas"/>
<owl:Class rdf:about="http://example.org/pizzas#Pizza"/>
<owl:Class rdf:about="http://example.org/pizzas#Human"/>
<owl:ObjectProperty rdf:about="http://example.org/pizzas#hasPizza">
<rdfs:domain rdf:resource="http://example.org/pizzas#Human"/>
<rdfs:range rdf:resource="http://example.org/pizzas#Pizza"/>
</owl:ObjectProperty>
<owl:NamedIndividual rdf:about="http://example.org/pizzas#Jim">
<rdf:type rdf:resource="http://example.org/pizzas#Human"/>
<pizzas:hasPizza>
<owl:NamedIndividual rdf:about="http://example.org/pizzas#CheesePizza">
<rdf:type rdf:resource="http://example.org/pizzas#Pizza"/>
</owl:NamedIndividual>
</pizzas:hasPizza>
</owl:NamedIndividual>
</rdf:RDF>
或相同的,在更可讀的龜:
@prefix : <http://example.org/pizzas#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix pizzas: <http://example.org/pizzas#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
pizzas:Jim
a pizzas:Human , owl:NamedIndividual ;
pizzas:hasPizza pizzas:CheesePizza .
pizzas:hasPizza
a owl:ObjectProperty ;
rdfs:domain pizzas:Human ;
rdfs:range pizzas:Pizza .
pizzas:Human
a owl:Class .
pizzas:Pizza
a owl:Class .
<http://example.org/pizzas>
a owl:Ontology .
pizzas:CheesePizza
a pizzas:Pizza , owl:NamedIndividual .
通知該斷言Jim hasPizza CheesePizza
是在一個三圖表。 hasPizza
對象屬性的域和範圍公理是兩個三元組:hasPizza rdfs:domain Human
和hasPizza rdfs:range Pizza
。 SPARQL查詢將查詢模式與圖中的三元組進行匹配。因此,從查詢,如:
prefix : <http://example.org/pizzas#>
select ?x ?y where {
?x :hasPizza ?y
}
就會得到結果如
$ arq --data pizzas.ttl --query query.sparql
-----------------------
| x | y |
=======================
| :Jim | :CheesePizza |
-----------------------
,因爲有一個三在其謂語是:hasPizza
圖,以及三重具有:Jim
爲主題,和:CheesePizza
作爲對象。這聽起來像你實際上要求的:hasPizza
屬性的域和範圍,這也很容易檢索。使用這樣的查詢:
prefix : <http://example.org/pizzas#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?domain ?range where {
:hasPizza rdfs:domain ?domain ;
rdfs:range ?range .
}
,你會得到這樣的結果:
$ arq --data pizzas.ttl --query query.sparql
-------------------
| domain | range |
===================
| :Human | :Pizza |
-------------------
難道您發佈本體的RDF版本?類不直接通過OWL中的屬性關聯,它通常通過存在限制公理完成。因此打開你的本體的RDF版本並查看構造;您可以嘗試將其與SPARQL查詢進行匹配。 – loopasam
聽起來你更有可能擁有一個對象屬性hasPizza,它的_rdfs:domain_和_rdfs:range_分別是'Human'和'Pizzas'。儘管如此,搜索也相對容易,但這是一項獨特的任務。 –