我确实创建了以下简单的本体,如下面的图片和代码所示。 My ontology但是我无法查询这个本体。
如果此查询比SELECT查询为真,则我想进行AKS查询,如果为假,则进行CONSTRUCT查询。我想看看是否有一个类机器(后来是一个子类)通过数据属性与零件(后来是一个子类)连接在一起,然后提取了零件的注释。我试图结合以下答案:Answer1和Answer2。我的问题可能非常基础,但似乎无法解决这个问题。谢谢您的帮助和耐心
我的查询是这样的(我在这里只输入了一次前缀):
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#>
ASK { ?machine base:partOf ?part .
?part rdfs:comment ?comment}
SELECT ?machine ?part ?comment
WHERE {
?machine base:partOf ?part .
?part rdfs:comment ?comment.
}
CONSTRUCT {?part rdfs:comment ?comment}
WHERE { ?machine base:partOf ?part .
?part rdfs:comment ?comment}
本体
<!-- http://www.semanticweb.org/linus/ontologies/2019/5/untitled-ontology-11#partOf -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/linus/ontologies/2019/5/untitled-ontology-11#partOf">
<rdfs:domain rdf:resource="http://www.semanticweb.org/linus/ontologies/2019/5/untitled-ontology-11#part"/>
<rdfs:range rdf:resource="http://www.semanticweb.org/linus/ontologies/2019/5/untitled-ontology-11#machine"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/linus/ontologies/2019/5/untitled-ontology-11#machine -->
<owl:Class rdf:about="http://www.semanticweb.org/linus/ontologies/2019/5/untitled-ontology-11#machine"/>
<!-- http://www.semanticweb.org/linus/ontologies/2019/5/untitled-ontology-11#part -->
<owl:Class rdf:about="http://www.semanticweb.org/linus/ontologies/2019/5/untitled-ontology-11#part"/>
感谢您的帮助和耐心!