我的本體論是關於雞尾酒。這是一個名爲 「餘輝」Sparql查詢限制列表(相當於)protégé
<owl:Class rdf:about="&cocktails;AfterGlow">
<owl:equivalentClass>
<owl:Class>
<owl:intersectionOf rdf:parseType="Collection">
<owl:Restriction>
<owl:onProperty rdf:resource="&cocktails;aPourIngredient"/>
<owl:someValuesFrom rdf:resource="&cocktails;JusAnanas"/>
</owl:Restriction>
<owl:Restriction>
<owl:onProperty rdf:resource="&cocktails;aPourIngredient"/>
<owl:someValuesFrom rdf:resource="&cocktails;JusOrange"/>
</owl:Restriction>
<owl:Restriction>
<owl:onProperty rdf:resource="&cocktails;aPourIngredient"/>
<owl:someValuesFrom rdf:resource="&cocktails;SiropGrenadine"/>
</owl:Restriction>
<owl:Restriction>
<owl:onProperty rdf:resource="&cocktails;aPourDescription"/>
<owl:hasValue>Descriptoion AfterGlow</owl:hasValue>
</owl:Restriction>
<owl:Restriction>
<owl:onProperty rdf:resource="&cocktails;aPourTitre"/>
<owl:hasValue>AfterGlow</owl:hasValue>
</owl:Restriction>
</owl:intersectionOf>
</owl:Class>
</owl:equivalentClass>
<rdfs:subClassOf rdf:resource="&cocktails;Cocktail"/>
</owl:Class>
JusOrange
意味着橙汁 JusAnanas
雞尾酒意味着菠蘿汁
aPourIngredient
是property
,這意味着 「已(含)成分」
這是請求列出我所有的雞尾酒與他們的收縮
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX : <http://www.semanticweb.org/cocktails#>
SELECT *
WHERE {
?Cocktail rdfs:subClassOf :Cocktail.
?Cocktail owl:equivalentClass ?restriction .
}
我如何申請例如 「選擇包含JusAnanas和JusOrange所有雞尾酒」
你可以在這裏找到我的本體論:
https://s3-eu-west-1.amazonaws.com/ontologycero/cocktailsOnthology.owl
我已經已經發現了一個醜陋的請求,但它不可用,因爲我們必須知道使用這種請求的本體。
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX : <http://www.semanticweb.org/cocktails#>
SELECT *
WHERE {
?Cocktail rdfs:subClassOf :Cocktail.
?Cocktail owl:equivalentClass ?restriction .
?restriction owl:intersectionOf ?intersection.
?intersection rdf:first ?ingredient1.
?intersection rdf:rest ?rest1.
?rest1 rdf:first ?ingredient2.
?rest1 rdf:rest ?rest2.
?rest2 rdf:first ?ingredient3.
?ingredient1 owl:someValuesFrom :JusAnanas.
?ingredient2 owl:someValuesFrom :JusOrange.
}
謝謝,但它不工作。你的要求給我所有的雞尾酒包含:JusAnanas OR:JusOrange。我需要含有的雞尾酒:JusAnanas AND:JusOrange – amdev 2015-02-09 21:34:01
如何添加另一種成分。這會比你的更好,我認爲你無論如何都能給出正確的答案。我編輯了我的答案。 – Artemis 2015-02-10 09:47:38