使用sparql从protege本体中提取允许的食物

时间:2013-03-29 12:33:33

标签: sparql owl protege

我为食物创建了一个本体论,以确定哪些食物是允许的,哪些不是。目前,我正在尝试使用Protégé中的SPARQL查询提取所有允许的食物。我的SPARQL查询是:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX malay: <http://www.semanticweb.org/ontologies/2013/2/OntologyMalayIndigenousHealthKnowledge.owl#>

SELECT ?subject ?value
WHERE {
  ?subject rdfs:subClassOf malay:Oily . 
  ?subject ?property ?value .
}

但是,此查询只列出了类中的所有属性和关系。例如,

…
DogShark    isEnhance some Calcium
DogShark    hasRestriction only Allowed
…

我想要做的是列出所有允许的食物。 Allowed条件位于Restriction类中,与hasRestriction对象属性有关系。提取此类信息的正确方法是什么? 这是一个示例OWL文件。

<owl:Class rdf:about="http://www.semanticweb.org/ontologies/2013/2/OntologyMalayIndigenousHealthKnowledge.owl#Fresh_Tuber_Tapioca">
    <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/ontologies/2013/2/OntologyMalayIndigenousHealthKnowledge.owl#Tubers"/>
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="http://www.semanticweb.org/ontologies/2013/2/OntologyMalayIndigenousHealthKnowledge.owl#hasLevel"/>
            <owl:allValuesFrom rdf:resource="http://www.semanticweb.org/ontologies/2013/2/OntologyMalayIndigenousHealthKnowledge.owl#LevelTwo"/>
        </owl:Restriction>
    </rdfs:subClassOf>
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="http://www.semanticweb.org/ontologies/2013/2/OntologyMalayIndigenousHealthKnowledge.owl#hasRestriction"/>
            <owl:allValuesFrom rdf:resource="http://www.semanticweb.org/ontologies/2013/2/OntologyMalayIndigenousHealthKnowledge.owl#NotAllowed"/>
        </owl:Restriction>
    </rdfs:subClassOf>

0 个答案:

没有答案