[英]Sparql query to get all classes that are subclass of a “property class”
我需要通过向它们添加属性来“注释”某些类。 我需要这样做,以便让应用程序的视图层提取正确的类。
我所做的是:
创建一个名为uiProperty的对象属性,并编辑这些类以使其成为该类的子类:
uiProperty some
因此,我的课程的最终OWL代码如下所示:
rdfs:subClassOf owebs:RealEstate ,
[ rdf:type owl:Restriction ;
owl:onProperty owebs:uiProperty ;
owl:someValuesFrom owl:Thing
] ;
现在,我想构建一个sparql查询来获取这些类。 我做了以下工作:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owbes: <http://www.isep.org/desco/2015/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT $uri $label WHERE {
$uri rdfs:subClassOf owbes:RealEstate.
$uri rdfs:subClassOf $x.
$x owl:onProperty owbes:uiProperty.
$uri rdfs:label $label
}
该查询的结果是太多的类。 同一个班级被重复很多次。 例如:
为什么会这样呢? 以及如何解决?
我需要通过向它们添加属性来“注释”某些类。 我需要这样做,以便让应用程序的视图层提取正确的类。
这实际上就是注释属性 (例如rdfs:label)的用途。 您可以定义自己的注释属性,然后通过查询SPARQL来更直接地检索这些类。 例如,这是带有三个特殊类的本体:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:j.0="urn:ex:"
xmlns:owl="http://www.w3.org/2002/07/owl#">
<owl:Ontology rdf:about="http://www.semanticweb.org/taylorj/ontologies/2015/5/untitled-ontology-45"/>
<owl:Class rdf:about="urn:ex:C">
<j.0:isSpecialClass rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</j.0:isSpecialClass>
</owl:Class>
<owl:Class rdf:about="urn:ex:A">
<j.0:isSpecialClass rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</j.0:isSpecialClass>
</owl:Class>
<owl:Class rdf:about="urn:ex:B"/>
<owl:AnnotationProperty rdf:about="urn:ex:isSpecialClass"/>
</rdf:RDF>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.